From bef6c034a0e6fb37187c3f4bbdb2b5db284554a5 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 4 Apr 2024 01:03:03 +0700 Subject: [PATCH] UBERF-6318: Fix server drop connection on connect (#5174) Signed-off-by: Andrey Sobolev --- server/ws/src/client.ts | 2 +- server/ws/src/server.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/ws/src/client.ts b/server/ws/src/client.ts index 35c07168125..b90b530b43a 100644 --- a/server/ws/src/client.ts +++ b/server/ws/src/client.ts @@ -53,7 +53,7 @@ export class ClientSession implements Session { useCompression: boolean = true useBroadcast: boolean = false sessionId = '' - lastRequest = 0 + lastRequest = Date.now() total: StatisticsElement = { find: 0, tx: 0 } current: StatisticsElement = { find: 0, tx: 0 } diff --git a/server/ws/src/server.ts b/server/ws/src/server.ts index 434811e6200..0959ac76b1a 100644 --- a/server/ws/src/server.ts +++ b/server/ws/src/server.ts @@ -144,12 +144,12 @@ class TSessionManager implements SessionManager { } const now = Date.now() const diff = now - s[1].session.lastRequest - if (diff > 60000) { + if (diff > 60000 && this.ticks % 10 === 0) { console.log('session hang, closing...', h[0], s[1].session.getUser()) void this.close(s[1].socket, h[1].workspaceId, 1001, 'CLIENT_HANGOUT') continue } - if (diff > 20000 && this.ticks % 10 === 0) { + if (diff > 20000 && diff < 60000 && this.ticks % 10 === 0) { void s[1].socket.send( h[1].context, { result: 'ping' },