Reconnection after wifi lost possible?
dired opened this issue · 1 comments
dired commented
I tried some options (maybe I missed some others), to reconnect to the mqtt broker after a wifi outage.
After wifi reconnects successfully (WiFi.reconnect();
) , I try to reconnect mqtt but neither
while (!mqtt.connect("arduino", "public", "public")) {
Serial.print(".");
delay(1000);
}
nor
mqtt.disconnect();
delay(1000);
mqtt.begin(client);
while (!mqtt.connect("arduino", "public", "public")) {
Serial.print(".");
delay(1000);
}
do the trick.
It does not successfully connect again.
At this point I can ping the device again, apparently wifi-reconnect does work.
But the error I get, when I print with Serial.print(mqtt.getLastError());
is "-6" ( LWMQTT_NETWORK_FAILED_WRITE = -6,
).
I don't know what the issue seems to be for it to not reconnect to the mqtt broker again. I can now reboot the device, but I would love to use this library with reconnect without "cheating".
hideakitai commented
Fixed by #19