jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.58k stars 767 forks source link

Websocket Reconnection/Heartbeat #9

Closed tsujp closed 6 years ago

tsujp commented 6 years ago

I can't see anything in the implementation for heartbeat checks (although this could be done by someone using the library).

Also, is there any chance we could get automatic re-connections to the socket if the network connection drops?

jaggedsoft commented 6 years ago

Thanks for your suggestion! The heartbeat keepalive is performed automatically but this only applies to the User Data websocket endpoint. I am working on a solution to reconnect other websocket connections automatically. I will keep you updated

jaggedsoft commented 6 years ago

I am testing a build with this feature. Once I am sure it is stable I will publish a release

jaggedsoft commented 6 years ago

I believe it works as intended, will continue testing it. For now I am pushing a new build No changes are necessary, just npm update from your project directory and it will automatically reconnect these types of websocket connections: chart, depthCache, candlesticks, userData

jaggedsoft commented 6 years ago

Currently the websocket only attempts to reconnect once. If that attempt fails it stops trying to reconnect

I am planning on making it keep retrying automatically if it fails the first attempt