Terminate connection on timeout

If a connection has timed out the most likely cause is the connection
going stale, in which case calling close could take up to 30 seconds
before the ws lib gives up on waiting for the close message.  Terminate
the connection instead on the Node.js side.  Note that Firefox does not
permit applications from closing connections with a code other than
1000, or in the range 3000-4999.
This commit is contained in:
Hornwitser committed 2021-09-28 21:24:42 +02:00
1 parent f529457f96
commit 4a72c14b74
3 files changed
+10 -14

No files matched your search

+1 -1
View File
@@ -136,7 +136,7 @@ class WsServer {
let timeoutId = setTimeout(() => {
logger.verbose(`WsServer | closing ${req.socket.remoteAddress} after timing out on handshake`);
wsRejectedConnectionsCounter.inc();
socket.close(1008, "Handshake timeout");
socket.terminate();
this.pendingSockets.delete(socket);
}, 30*1000);