Merge pull request #91 from cjkas/fix/close-stalled-ws-clients

fix: close WebSocket clients whose queue is full
This commit is contained in:
cjkas 2026-10-21 20:01:47 +02:00 • committed by GitHub
commit 9696489554
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -210,7 +210,12 @@ void SocketEmitter::wsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client
slots[slot].connectedAt = millis(); slots[slot].connectedAt = millis();
slots[slot].lastPing = 0; slots[slot].lastPing = 0;
client->text("Connected"); client->text("Connected");
client->setCloseClientOnQueueFull(false); // A client that stops reading (a frozen browser tab) keeps its TCP link
// up, so nothing else ever closes it, and every message dropped for it
// logged a warning that held up loop() for ~10ms. Closing it frees the
// queue; the page and Home Assistant reconnect and get the full state
// again from delayInit().
client->setCloseClientOnQueueFull(true);
sockEmit.delayInit(slot); sockEmit.delayInit(slot);
} }
break; break;