fix: keep terminal sessions alive
Deploy Dashboard (Dev) / deploy-dev (push) Successful in 2m23s

Add WebSocket and SSH keepalives so idle dashboard terminal sessions stay connected across proxies and long-running idle periods.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gan, Jimmy
2026-03-06 16:11:43 +08:00
parent aaabb8a373
commit c9f06fbbbb
2 changed files with 11 additions and 1 deletions
+4
View File
@@ -72,6 +72,8 @@ async def ws_endpoint(websocket: WebSocket, host: str = Query("nas")):
conn = await asyncssh.connect(
h["host"], username=h["user"],
client_keys=[h["key"]], known_hosts=_known_hosts,
keepalive_interval=30,
keepalive_count_max=3,
)
except Exception:
_active_sessions.discard(session_id)
@@ -108,6 +110,8 @@ async def ws_endpoint(websocket: WebSocket, host: str = Query("nas")):
else:
process.stdin.write(data)
elif "text" in msg and msg["text"]:
if msg["text"] == "__ping__":
continue
process.stdin.write(msg["text"].encode())
except WebSocketDisconnect:
pass