UBERF-8280: Ping properly from server (#6733)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-09-26 16:52:09 +07:00 committed by GitHub
parent 28fffa883f
commit cc67c2792e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 1 deletions

View File

@ -57,6 +57,8 @@ export class ClientSession implements Session {
sessionId = ''
lastRequest = Date.now()
lastPing: number = Date.now()
total: StatisticsElement = { find: 0, tx: 0 }
current: StatisticsElement = { find: 0, tx: 0 }
mins5: StatisticsElement = { find: 0, tx: 0 }

View File

@ -198,8 +198,13 @@ class TSessionManager implements SessionManager {
void this.close(this.ctx, s[1].socket, wsId)
continue
}
if (lastRequestDiff + (1 / 10) * lastRequestDiff > this.timeouts.pingTimeout) {
if (
lastRequestDiff + (1 / 10) * lastRequestDiff > this.timeouts.pingTimeout &&
now - s[1].session.lastPing > this.timeouts.pingTimeout
) {
// We need to check state and close socket if it broken
// And ping other wize
s[1].session.lastPing = now
if (s[1].socket.checkState()) {
s[1].socket.send(
workspace.context,

View File

@ -74,6 +74,7 @@ export interface Session {
mins5: StatisticsElement
lastRequest: number
lastPing: number
isUpgradeClient: () => boolean