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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user