BitMEX / api-connectors

Libraries for connecting to the BitMEX API.
https://www.bitmex.com/app/restAPI
910 stars 795 forks source link

Bitmex Delta Server - Nonce is not increasing #73

Closed AlexB1337 closed 6 years ago

AlexB1337 commented 6 years ago

Hi all,

I am trying to use Delta Server for streaming the data from my real account. The problem is that I get the "nonce is not increasing" error quite often. I use a separate set of API Keys for Delta Server.

Does anyone have an idea how to solve this issue? Thanks.

WebSocket [ERROR]: WebSocket closed with code 1006
WebSocket [INFO]: Retry in 1000 ms
WebSocket [INFO]: Reconnecting...
WebSocket [ERROR]: Unexpected response from server [400]: {"error":"Nonce is not increasing. This nonce: 1516748266508, last nonce: 1516748266508"}
WebSocket [INFO]: The WebSocket will terminate. Please manually reconnect.
WebSocket [ERROR]: WebSocket closed unexpectedly.
Client closed due to unrecoverable WebSocket error. Please check errors above.
ryanfox commented 6 years ago

The node websocket client used a different nonce scheme - the non-increasing nonce should be fixed now.

annugaurish commented 6 years ago

I have solved this problem by making changes in createSocket.js Added following code in the createSocket function

wsClient.onreconnect = function() { wsClient.url = makeEndpoint(options); debug('Reconnecting to BitMEX at ', wsClient.url); };

and in ReconnectionSocket.js added the following line in reconnect prototype

this.onreconnect();

this is to be added before this.open(this.url);