feat: 增加ws重连机制

This commit is contained in:
Baobhan Sith
2025-04-16 15:19:06 +08:00
parent a83b346956
commit 84f0368811
4 changed files with 68 additions and 7 deletions
+2 -2
View File
@@ -102,8 +102,8 @@ export const establishSshConnection = (
privateKey: connDetails.privateKey,
passphrase: connDetails.passphrase,
readyTimeout: timeout,
keepaliveInterval: 30000, // 保持连接
keepaliveCountMax: 3,
keepaliveInterval: 10000, // 保持连接
keepaliveCountMax: 10,
};
const readyHandler = () => {
+1 -1
View File
@@ -92,7 +92,7 @@ export const initializeWebSocket = (server: http.Server, sessionParser: RequestH
extWs.isAlive = false;
extWs.ping(() => {});
});
}, 30000); // 30 秒心跳间隔
}, 60000); // 增加到 60 秒心跳间隔
// --- WebSocket 升级处理 (认证) ---
server.on('upgrade', (request: Request, socket, head) => {