-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Old websockets do not seem to be terminated #170
Comments
Can the authors comment on this?? Isn't this ambiguous as a connection might still be open, and we might be opening a new one. Then server may send the close frame and onclose will be fired on client side, closing the new working connection !! |
My problem turned out to be ping pong |
@chongma Could you please elaborate on this? Did the old connection keep pinging the server even after closing? |
@DamiToma The problem was on the server side. It wasn't correctly handling the ping pong. Eventually I moved to graphql subscriptions. So I didn't need to manually configure websockets any more. |
@DamiToma The server code is something like this where it keeps a heartbeat unless the socket is closed function heartbeat() {
this.isAlive = true;
}
function initialiseWebsocket(name) {
const wss = new WebSocketServer({ noServer: true });
wss.on('connection', function (ws) {
ws.isAlive = true;
ws.on('pong', heartbeat);
});
const interval = setInterval(function ping() {
wss.clients.forEach(function each(ws) {
if (ws.isAlive === false) return ws.terminate();
ws.isAlive = false;
ws.ping();
});
}, 30000);
wss.on('close', function close() {
clearInterval(interval);
});
console.log(`Creating websocket ${name}`)
return wss
} |
I am having a strange issue with websockets. I have my websocket server behind an apache httpd 2.4.51 proxy and the sockets keep disconnecting after 30 seconds or so. I am trying to investigate the issue but in the meantime I have installed reconnecting-websockets and it seems to work.
But now I have discovered that the chrome tab eventually runs out of memory and looking into the network tab on chrome reveals that lots of duplicate websockets are being created and they have status "101" whereas sometimes i get one that says status "finished"
I am using VueX to try to store a single instance of each reconnecting websocket, essentially like this
The issue may be related to the way that the server is terminating the connection but reconnecting-websockets shouldn't create a new one while the old one is still open?
The text was updated successfully, but these errors were encountered: