FIX: the server now closes the socket after 30s of no pong

This commit is contained in:
kharhamel 2020-11-09 12:12:52 +01:00
parent a14e227706
commit 85f2dabe6c
3 changed files with 16 additions and 2 deletions

View file

@ -47,4 +47,13 @@ export function emitError(Client: ExSocketInterface, message: string): void {
Client.send(serverToClientMessage.serializeBinary().buffer, true);
}
console.warn(message);
}
}
export const pongMaxInterval = 30000; // the maximum duration (in ms) between pongs before we shutdown the connexion.
export function refresLogoutTimerOnPong(ws: ExSocketInterface): void {
if(ws.pongTimeout) clearTimeout(ws.pongTimeout);
ws.pongTimeout = setTimeout(() => {
ws.close();
}, pongMaxInterval);
}