mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:50:42 +00:00
fix(gateway): start ping timer only after client authentication in ws-connection
Agent-Logs-Url: https://github.com/openclaw/openclaw/sessions/30df0b08-4389-40c2-91e9-6f9189914f7b Co-authored-by: BunsDev <68980965+BunsDev@users.noreply.github.com>
This commit is contained in:
committed by
Val Alexander
parent
99f12b8c4d
commit
809a42d172
@@ -267,16 +267,7 @@ export function attachGatewayWsConnectionHandler(params: AttachGatewayWsConnecti
|
||||
payload: { nonce: connectNonce, ts: Date.now() },
|
||||
});
|
||||
|
||||
const pingTimer = setInterval(() => {
|
||||
if (!client) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
socket.ping();
|
||||
} catch {
|
||||
// close() clears the timer; ping can race with a socket already entering CLOSING.
|
||||
}
|
||||
}, 25_000);
|
||||
let pingTimer: ReturnType<typeof setInterval> | undefined;
|
||||
|
||||
const close = (code = 1000, reason?: string) => {
|
||||
if (closed) {
|
||||
@@ -284,7 +275,9 @@ export function attachGatewayWsConnectionHandler(params: AttachGatewayWsConnecti
|
||||
}
|
||||
closed = true;
|
||||
clearTimeout(handshakeTimer);
|
||||
clearInterval(pingTimer);
|
||||
if (pingTimer !== undefined) {
|
||||
clearInterval(pingTimer);
|
||||
}
|
||||
releasePreauthBudget();
|
||||
if (client) {
|
||||
clients.delete(client);
|
||||
@@ -435,6 +428,13 @@ export function attachGatewayWsConnectionHandler(params: AttachGatewayWsConnecti
|
||||
releasePreauthBudget();
|
||||
client = next;
|
||||
clients.add(next);
|
||||
pingTimer = setInterval(() => {
|
||||
try {
|
||||
socket.ping();
|
||||
} catch {
|
||||
// close() clears the timer; ping can race with a socket already entering CLOSING.
|
||||
}
|
||||
}, 25_000);
|
||||
return true;
|
||||
},
|
||||
setHandshakeState: (next) => {
|
||||
|
||||
Reference in New Issue
Block a user