Closed jaggedsoft closed 7 years ago
this is my error - when I provided the example I wrote the comment incorrectly
reconnecting: function (retry) {
((opts.verbose) ? console.log('Websocket Retrying: ', retry) : '');
// change to false to stop retrying
return true;
}
should be
reconnecting: function (retry) {
((opts.verbose) ? console.log('Websocket Retrying: ', retry) : '');
// change to true to stop retrying
return false;
}
i have pushed a fix, the default is set to reconnect the socket now as @dparlevliet suggests.
you also can redefine what has to happen on disconnected like this:
var websocketsclient = bittrex.websockets.listen( function( data ) { // etc ... });
websocketsclient.serviceHandlers.disconnected = function () { // do something ... };
these are all possible serviceHandlers:
bound: function() { console.log("Websocket bound"); },
connectFailed: function(error) { console.log("Websocket connectFailed: ", error); },
connected: function(connection) { console.log("Websocket connected"); },
disconnected: function() { console.log("Websocket disconnected"); },
onerror: function (error) { console.log("Websocket onerror: ", error); },
messageReceived: function (message) { console.log("Websocket messageReceived: ", message); return false; },
bindingError: function (error) { console.log("Websocket bindingError: ", error); },
connectionLost: function (error) { console.log("Connection Lost: ", error); },
reconnecting: function (retry /* { inital: true/false, count: 0} */) {
console.log("Websocket Retrying: ", retry);
//return retry.count >= 3; /* cancel retry true */
return true;
}
You are both very awesome! Thank you for everything you have done. I am grateful!!
https://nextlocal.net https://nextlocal.me https://nextlocal.ca https://ravanaorganics.com https://buykratombulkusa.com
Thank you for this awesome library!! Is there a way to automatically reconnect the websocket in case it gets disconnected?
listen example
Currently when it gets disconnected all I see is "Connection aborted" in the console Thanks in advance! @dparlevliet @n0mad01