fix: reduce WebSocket refresh interval to 10s for live MQTT data

- 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 <noreply@anthropic.com>
This commit is contained in:
Sam 2026-03-02 23:58:14 +01:00
parent 0dce8a9d80
commit d9626108e6
2 changed files with 2 additions and 2 deletions

View file

@ -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

View file

@ -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<DashboardData | null>(null);