increase timeouts for pings

This commit is contained in:
HF 2022-06-26 21:19:19 +02:00
parent e820032a3a
commit a9c2289d4f
2 changed files with 4 additions and 6 deletions

View File

@ -60,14 +60,14 @@ class SocketClient extends EventEmitter {
checkHealth() {
if (this.readyState === WebSocket.OPEN) {
const now = Date.now();
if (now - 14000 > this.timeLastPing) {
if (now - 20000 > this.timeLastPing) {
// server didn't send anything, probably dead
console.log('Server is silent, killing websocket');
this.readyState = WebSocket.CLOSING;
this.ws.close();
}
if (now - 10000 > this.timeLastSent) {
// make sure we send something at least all 12s
if (now - 43000 > this.timeLastSent) {
// make sure we send something at least all 45s
this.sendWhenReady(Ping.dehydrate());
}
}

View File

@ -368,9 +368,7 @@ class SocketServer {
let client = it.next();
while (!client.done) {
const ws = client.value;
if (ws.readyState === WebSocket.OPEN
&& ws.user
) {
if (ws.readyState === WebSocket.OPEN) {
const canvasId = ws.canvasId || 0;
const { ip } = ws.user;
// only count unique IPs per canvas