You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My communication pattern is receiving human pressed keys which could be very fast and then very slow. Each key press gets a response sent. And the pings are more frequent and used to calculate round trip time. I start seeing problems when using pings/messages together and no problems at all if they are used separately (i.e. only pings, or only messages), regardless of the comm frequency. I'll keep investigating.
The text was updated successfully, but these errors were encountered:
After further investigation, it seems at some point AsyncWebSocketClient::_onAck stops getting called. And as messages are never flushed control pings never get sent neither (finished=0) so they never get an ack neither.
This happens after a burst of messages arrive very fast/at the same time. After every message received, I send an "OK" response. A ping and these "OK"s might get intertwined.
If I keep receiving messages (and responding "OK") at one point the message queue fills up, start getting ERROR: Too many messages queued message, but the message queue doesn't need to be full to create this stuck state.
I've added this debug code to look into the state of the queue each time I ping
void AsyncWebSocketClient::ping(uint8_t *data, size_t len)
{
ets_printf("ping\n");
int i = 0;
for (auto it = _controlQueue.begin(); it != _controlQueue.end(); ++it)
{
ets_printf("ping ctrl q %d) fin%d op%d\n", i++, (*it)->finished() ? 1 : 0, (*it)->opcode());
}
i = 0;
for (auto it = _messageQueue.begin(); it != _messageQueue.end(); ++it)
{
auto *x = (AsyncWebSocketBasicMessage *)(*it);
ets_printf("ping mesg q %d) fin%d bwf%d len%d sent%d ack%d acked%d\n", i++, (*it)->finished() ? 1 : 0, (*it)->betweenFrames(), x->_len, x->_sent, x->_ack, x->_acked);
}
if (_status == WS_CONNECTED)
_queueControl(new AsyncWebSocketControl(WS_PING, data, len));
}
EDIT: Already found the problem. Added a PR with the full description and solution #1390
I think it's an omission here
ESPAsyncWebServer/src/AsyncWebSocket.cpp
Line 527 in f71e3d4
I believe it should do the same cleanup as it does for message packets, also for control packets.
Or maybe the following
if
could be awhile
to flush all of them out.ESPAsyncWebServer/src/AsyncWebSocket.cpp
Line 498 in f71e3d4
My communication pattern is receiving human pressed keys which could be very fast and then very slow. Each key press gets a response sent. And the pings are more frequent and used to calculate round trip time. I start seeing problems when using pings/messages together and no problems at all if they are used separately (i.e. only pings, or only messages), regardless of the comm frequency. I'll keep investigating.
The text was updated successfully, but these errors were encountered: