From af45e65ad726f1813e54b05756255499bff8ba12 Mon Sep 17 00:00:00 2001 From: Go1c <1c@live.cn> Date: Tue, 14 Apr 2026 16:57:37 +0800 Subject: [PATCH] fix: enable WebSocket ping heartbeat to detect dead connections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit heartbeat_interval was defined in config (default 30s) but never used — ping_interval/ping_timeout were both None, so silently dead connections were never detected and the receive loop hung indefinitely. Now passes heartbeat_interval to websockets ping_interval and ping_timeout. A missed pong raises ConnectionClosed, exits _listen(), and triggers the reconnect loop which re-syncs any missed events. --- fns_cli/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fns_cli/client.py b/fns_cli/client.py index 47395fb..ac39a9b 100644 --- a/fns_cli/client.py +++ b/fns_cli/client.py @@ -121,11 +121,12 @@ async def _connect(self) -> None: ) log.info("Connecting to %s", url) + interval = self.config.client.heartbeat_interval self.ws = await websockets.connect( url, max_size=128 * 1024 * 1024, - ping_interval=None, - ping_timeout=None, + ping_interval=interval, + ping_timeout=interval, close_timeout=10, ) log.info("WebSocket connected, sending auth")