Closed HamzaHajeir closed 3 years ago
Found bugs at this state, Closing until it's fixed.
Hi
I've fixed and tested the code in my environment.
All nodes are responding well between router reboots and after long-time missing broker (on My PC OFF).
Hi
Fix to #7 where this is the scenario : = Router reboots = MQTT senses disconnection, onDisconnect called :
if(autorestart && WiFi.status()==WL_CONNECTED) h4.every(H4MQ_RETRY,[this](){ connect(); },nullptr,H4P_TRID_MQRC,true);
= after H4MQ_RETRY (10 seconds) , it callsconnect()
:connect()
which ignores connection if there's a created instance of PANGO::TCP.Here I've managed to (delay) the re-connection So network event can occur before trying to reconnect to MQTT. https://github.com/HamzaHajeir/h4plugins/commit/3e0b6236c7f0287ed969fa2b95b705edbdf188a0
This pull request contains another commit that solves another problem :
The problem is : After MQTT is established again after a reboot, and after 30 seconds of unreachable MQTT server : onDisconnect is called, in which it doesn't activate the reconnection lines because
_discoDone = true
.That's because It doesn't pass through onConnect() callback function that sets
_discoDone
tofalse
.Removing _discoDone codes in H4P_AsyncMQTT solves the issue. And MQTT reconnects all the time without any issue.
Hope it helps
Hamza Hajeir