You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that my application breaks on sending a message while websocket still be connecting to the server. This can be handled in application side, but I think it would be good to have some timer or have a queue of messages to send on reconnecting in this library side. This isn't elegant but here it is what I did to solve the problem.
this.send = function (data) {
if (ws) {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'send', self.url, data);
}
//if socket is connecting wait 500ms to retry send the message
if(ws.readyState === 0){
return setTimeout(()=>this.send(data),500);
}
return ws.send(data);
} else {
throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';
}
};
The text was updated successfully, but these errors were encountered:
I noticed that my application breaks on sending a message while websocket still be connecting to the server. This can be handled in application side, but I think it would be good to have some timer or have a queue of messages to send on reconnecting in this library side. This isn't elegant but here it is what I did to solve the problem.
The text was updated successfully, but these errors were encountered: