Open mcspr opened 5 years ago
I believe this is related to the marvinroger/async-mqtt-client#105 onPoll tracks last ping: https://github.com/marvinroger/async-mqtt-client/blob/8bd918bfeb2f197afa8b0cb5d278ab2942c62ccb/src/AsyncMqttClient.cpp#L447 But sendPing function will never update last ping time if it can't send ping (as established above): https://github.com/marvinroger/async-mqtt-client/blob/8bd918bfeb2f197afa8b0cb5d278ab2942c62ccb/src/AsyncMqttClient.cpp#L614
Bug description
When MQTT broker server is physically disconnected from the network (for example, network cable is removed), device still thinks that connection is OK. Neither onDisconnect or onTimeout firing for MQTT module. mqtt.info shows state as connected, mqtt.reset finally resets it
While this seems like a bug in async mqtt client / asynctcp, still recording it here as it may be important "feature" to know. And it may be fixed by manual keep-alive, tracking last successful mqttSend() call
Steps to reproduce
mqttQoS=1
,mqttKeep=300
,hbInterval 5
reset, wait until mqtt is connected on the deviceAdditional context
Using async-mqtt-client master (or v0.8.1, same thing), Core 2.3.0 & 2.5.2 lwip2 Network is Linux server, Router that is directly wired to the server and ESP connected to the Router's AP. Both on the same LAN network bridged together.
I waited for about 10 min and reconnected the cable, after which MQTT reconnection finally happened.
tcpdump on the router shows that device is still sending data, but it does look like it just tries to retransmit not acked data:
Small patch to the dev tree enables lwip debugging and shows that pcb is still ESTABLISHED https://github.com/xoseperez/espurna/compare/dev...mcspr:lwip/pcb-debug
One would expect that keep-alive would sort this out, but it does not. (and as quick google search answers suggest, regarding lwip tcp /app keepalive)
Device information