Comments (4)
Hi. Thanks for your comments.
I'm not sure exactly what the bug you're referring to is (could you describe it ? ;)). Regarding your questions, here's my answers :
- clearTimeout / clearInterval
You're probably right as for consistency I should use clearInterval but nodejs will handle it properly as explained in https://nodejs.org/api/timers.html#timers_class_timeout
This object is created internally and is returned from setTimeout() and setInterval(). It can be passed to either clearTimeout() or clearInterval() in order to cancel the scheduled actions
- ignoreCloseEvent
This is set to false when ws is opened, since close events should be handled. But if ws is explicitely closed by calling disconnect method, event will be ignored
- skipCloseEvent
It is needed since in case error event is triggered, there is no need to also handle the close event
- doRetry
It is also necessary since in case a connection error occurs, function will be retried automatically up to 10 times (I can tell you that sometimes it can take multiple retries before connection is established). See https://github.com/tim-kos/node-retry for information regarding retry library
- Noop ping
If you check the code for ping method, you will notice that when doing ws.ping(noop) ws library will actually do a ping('', true) and call the noop callback. Also in the version 3.2.0 (which is used by the gateway), the prototype of ping method is a bit different and does not accept a callback. For the moment, I don't see any reason to change the version used by gateway.
- Arrows
This would make code clearer I agree. Will keep it in mind.
from crypto-exchanges-gateway.
Hi
startWs will start the WS server, so that you can open WS connections to the gateway. The WS connections to the exchanges will only be opened on-demand.
WS workflow is as below :
- gateway is listening on ws://127.0.0.1:8001
- ws client 1 connects to ws://127.0.0.1:8001/exchanges/binance/tickers/USDT-NEO
- gateway will open a ws connection to binance to get realtime tickers info for USDT-NEO
- ws client 2 connects to ws://127.0.0.1:8001/exchanges/binance/tickers/USDT-NEO
- gateway will not open a new ws connection to binance since one already exist
- ws client 1 disconnect
- ws connection to binance still exist because it is still used for the second client
- ws client 2 disconnect
- ws connection to binance still exist because it is still used for the second client
At any moment, you can check which WS connections are opened for a given exchange by doing a REST request to http://127.0.0.1:8000/exchanges/binance/connections
See https://github.com/aloysius-pgast/crypto-exchanges-gateway/blob/master/doc/ws/endpoints.adoc for WS endpoints exposed by the gateway
from crypto-exchanges-gateway.
Awesome!!! Thanks for all the replies, I am closing this issue :)
from crypto-exchanges-gateway.
I am sorry if this sounds like a silly question but I had to ask, you seem to be creating a different websocket inside the session file but for each exchange you have a stream client and an exchange class which seems to be used by subscription manager of that exchange which in turn is used inside the routes file for that exchange, when I go to gateway.js, it seems to trigger startWs inside ws/main.js which in turn manages uses the websocket inside the session object, where and how does routes/subscription manager tie into this and more importantly, can you directly use the routes without the whole session, registry and storage thingies
from crypto-exchanges-gateway.
Related Issues (20)
- npm install ERROR HOT 3
- Add cfg.exchanges.kucoin.password into environment variables HOT 3
- Tiny issue of the doc HOT 1
- Okex doesn't work HOT 13
- User Authentication HOT 1
- Completed orders incorrectly sorted in UI when some orders are cancelled (Binance) HOT 2
- Updating pair in url (myOrders view) does not refresh pair chooser HOT 1
- Looking to autosell BTC/ETH HOT 6
- In Localhost installation, can only view "prices", & Order Books HOT 5
- Implement Kucoin V2 API HOT 2
- Crypto-exchange : dummy ethers HOT 1
- Klines for exchanges that only have a trades websocket? HOT 6
- MaxListenersExceededWarning HOT 8
- blocking call WS RPC subscribeToKlines HOT 7
- Question: WS kline or polling history candles? HOT 2
- Setting ports on docker command does not work HOT 1
- Install issue HOT 10
- Filter trade notifications to only emit my exchange's account trades HOT 5
- Could not query exchange for pair HOT 46
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crypto-exchanges-gateway.