From d9626108e6a4bb5d686717598dde1400740a9559 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Mar 2026 23:58:14 +0100 Subject: [PATCH] fix: reduce WebSocket refresh interval to 10s for live MQTT data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Client ping interval: 15s → 10s - Server timeout fallback: 20s → 12s - Ensures CPU/RAM values update promptly from MQTT store Co-Authored-By: Claude Opus 4.6 --- server/routers/dashboard.py | 2 +- web/src/hooks/useWebSocket.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/routers/dashboard.py b/server/routers/dashboard.py index 7a43f53..61ab0fa 100644 --- a/server/routers/dashboard.py +++ b/server/routers/dashboard.py @@ -91,7 +91,7 @@ async def ws_endpoint(ws: WebSocket) -> None: while True: # Wait for a client ping / keepalive; refresh on timeout too. try: - _msg = await asyncio.wait_for(ws.receive_text(), timeout=20.0) + _msg = await asyncio.wait_for(ws.receive_text(), timeout=12.0) except asyncio.TimeoutError: pass diff --git a/web/src/hooks/useWebSocket.ts b/web/src/hooks/useWebSocket.ts index e3bccf8..59e8c2d 100644 --- a/web/src/hooks/useWebSocket.ts +++ b/web/src/hooks/useWebSocket.ts @@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from "react"; import type { DashboardData } from "../api"; const WS_RECONNECT_MS = 5_000; -const WS_PING_INTERVAL_MS = 15_000; +const WS_PING_INTERVAL_MS = 10_000; export function useWebSocket() { const [data, setData] = useState(null);