Open imnotjoel opened 6 years ago
Code 1006 means the connection was closed improperly. See this stackoverflow answer for more info.
Does it happen consistently every time, or is it sporadic?
Hi @ryanfox It happens always after ~4 minutes
@dannyluong408 it's not unexpected that the socket would get disconnected after that amount of time. If you want to reconnect it, you could wrap your code in a retry block.
@imnotjoel is your network connection stable in general? One way you could get more information is to enable DEBUG - this will produce large amounts of output though.
I have this problem every single time. I don't seem to be able to catch the exception either for some reason (using Node lib).
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);
Dear Bitmex community,
Thank you annugaurish for your corrections. My Bitmex node client now does not crash but still reconnects every few seconds with a 1006 error. The same code was working fine 3 days ago. Can anyone explain why the client is continually disconnecting all of a sudden?
Faithfully,
Alexander
Thanks @annugaurish ! This solution fix the problem. Pull request needed :)
Welcome:)
same issue here a bit painful to have my bot stop completely from that crash...
I solved this problem by sending a raw ping every minute.
The client library has a socket variable holding the websocket object. So just setup an interval and send the ping like this:
client.socket.send('ping');
You may recieve messages like:
Unable to parse incoming data: pong
But its not a big deal i guess.
I'm in the middle of trying @annugaurish 's solution. Let me see if it's working well. But I wonder why there's no pull request about this?
We're having the same issue and @annugaurish solution does not seem to change anything.
I tried to fix with @annugaurish`s method, but that solution does not seem to change anything.
I solved this problem by sending a raw ping every minute. The client library has a socket variable holding the websocket object. So just setup an interval and send the ping like this:
client.socket.send('ping');
You may recieve messages like:
Unable to parse incoming data: pong
But its not a big deal i guess.
This work to me
I just made a small change in my local in the file: https://github.com/BitMEX/api-connectors/blob/master/official-ws/nodejs/lib/createSocket.js#L38
Adding an if, to not return this message if the answer is pong!
Resolved issue and no longer issues annoying message
Thanks for sharing
I have noticed re-connection errors and tried the above method but did not solve the issue.
Hi guys, I have the following issue. Hope you can give me a hand!
I tough it has to do with my connection.. But then I tried to run it in a ECS instance and I had the same issue.
Thanks in advance!