BitMEX / api-connectors

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

WebSocket closed with code 1006 #189

Open lliypuk opened 6 years ago

lliypuk commented 6 years ago

Hi! Some time ago I don't get any data from websocket and every time see:

WebSocket [INFO]: Connected. Connection opened. Client initialized, data is flowing. {"op":"subscribe","args":"instrument:XBTUSD"} WebSocket [ERROR]: WebSocket closed with code 1006 Connection closed. WebSocket [INFO]: Retry in 1000 ms WebSocket [INFO]: Reconnecting... WebSocket [INFO]: Connected. Connection opened. {"op":"subscribe","args":"instrument:XBTUSD"} WebSocket [ERROR]: WebSocket closed with code 1006 Connection closed. WebSocket [INFO]: Retry in 1000 ms WebSocket [INFO]: Reconnecting... WebSocket [INFO]: Connected. Connection opened. ....

What I do wrong?

bluworld commented 6 years ago

@ryanfox any clues on this issue?

I came across a similar error message.

For me, the websocket connection runs fine for the majority of the time, but occasionally I get 1006 error.

Manually stopping and restarting the delta server reconnects successfully with the websocket.

WebSocket [ERROR]: WebSocket closed with code 1006 WebSocket [INFO]: Retry in 60000 ms WebSocket [INFO]: Reconnecting... WebSocket [ERROR]: Unexpected response from server [400]: {"error":"Nonce is not increasing. This nonce: 1533921107915000, last nonce: 1533921107915000"} WebSocket [INFO]: The WebSocket will terminate. Please manually reconnect. Caught Websocket error: Error: closed before the connection is established at WebSocket.close (/mnt/c/Users/james/Google Drive/Business/Python/api-connectors-master/official-ws/nodejs/node_modules/ws/lib/WebSocket.js:271:21) at closeConnection (/mnt/c/Users/james/Google Drive/Business/Python/api-connectors-master/official-ws/nodejs/lib/ReconnectingSocket.js:70:23) at IncomingMessage.response.on (/mnt/c/Users/james/Google Drive/Business/Python/api-connectors-master/official-ws/nodejs/lib/ReconnectingSocket.js:84:9) at IncomingMessage.emit (events.js:187:15) at endReadableNT (_stream_readable.js:1081:12) at process._tickCallback (internal/process/next_tick.js:63:19)

lliypuk commented 6 years ago

I wrote support Bitmex, and they answered me about problems with websocket at time, when I have trouble with 1006 error, some time later web socket connected and work fine. But 2 days ago I received similar trouble, it was continuing 4-6 hours, and now it's ok. It is really bad, becouse I use it for recive actual price on market, and can't use API /quote endpoint, it switched off=(

ryanfox commented 6 years ago

Error 1006 indicates a low-level issue with the websocket. If there are no other issues and you are able to reconnect it was likely a network issue.

If you are receiving "nonce is not increasing" errors, you should upgrade from nonce-based authentication to the api-expires authentication method outlined here.