diff --git a/als_alert_screen.html b/als_alert_screen.html
index 3d083a2..ed18362 100644
--- a/als_alert_screen.html
+++ b/als_alert_screen.html
@@ -292,6 +292,13 @@
dataTimers[id] = setTimeout(() => {
delete machineData[id];
updateDisplay();
+
+ // NOWE: Jeśli dane są przestarzałe, zakładamy, że WebSocket to "zombie".
+ // Zabijamy go ręcznie, co wywoła onclose i sprowokuje ponowne połączenie.
+ if (wsMap[id] && wsStatus[id] === "connected") {
+ console.warn(`Brak danych dla ${id} - ubijam ciche połączenie`);
+ wsMap[id].close();
+ }
}, DATA_STALE_MS);
}
@@ -311,6 +318,7 @@
ws.onopen = () => {
wsStatus[id] = "connected";
refreshStatus();
+ resetStaleTimer(id); // NOWE: Startujemy timer od razu po otwarciu
};
ws.onmessage = (ev) => {
@@ -329,6 +337,11 @@
ws.onerror = () => {
wsStatus[id] = "error";
refreshStatus();
+
+ // NOWE: Jitter zapobiegający "Thundering Herd"
+ // Baza 5000ms + losowo od 0 do 3000ms
+ const reconnectDelay = RECONNECT_MS + Math.floor(Math.random() * 3000);
+ setTimeout(() => connect(id), reconnectDelay);
};
ws.onclose = () => {