fix: close WebSocket clients whose queue is full

A client that stops reading (a frozen browser tab) keeps its TCP link
alive, so neither AsyncTCP's ack timeout nor lwIP ever closes it.  With
setCloseClientOnQueueFull(false) every message dropped for it printed a
warning, and each warning held up loop() for about 10ms on the UART.
One such client stayed full for 44 minutes and made every step of
loop() slow while shades moved.

Closing it frees the queue.  The web UI and Home Assistant reconnect
and get the full state again from delayInit().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-21 19:51:46 +02:00
parent 63c2d180e0
commit e31eafe255

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;