Optimizing MQTT Stability on ESP32 with Keep-Alive Tuning or Reconnection Strategy

Hey guys in my previous work with MQTT on ESP32, I've faced challenges like frequent disconnections in unstable networks and inconsistent message delivery despite adjusting QoS levels and retry settings. l've tried different keep-alive intervals but still experience data loss during network drops. Should I prioritize fine-tuning the keep-alive interval to maintain a stable connection, or would implementing a more robust reconnection strategy be a better approach?
2 Replies
UC GEE
UC GEE3mo ago
Hey @Daniel kalu To address your challenges with MQTT on your ESP32 project,Try to consider implementing a robust reconnection strategy rather than solely fine-tuning the keep-alive.Reasons is because, frequent disconnections often stem from unstable network conditions, so enhancing your reconnection logic can help you to maintain a stable MQTT connection during network drops. And secondly, try to have thorough check on your WiFi connectivity and use a watchdog timer to handle hangs during reconnections. Additionally,ensure you're regularly calling client.loop() to keep the connection alive and process incoming messages effectively.
Daniel kalu
Daniel kalu3mo ago
Thanks! I'll put the reconnection plan into action, including watchdog timers and regular client.loop() calls.
Want results from more Discord servers?
Add your server