Drops MQTT/mosquitto connection on wifi router reboot.

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
larsbjorke
New user
Posts: 2
Joined: 26 Sep 2015, 14:05

Drops MQTT/mosquitto connection on wifi router reboot.

#1 Post by larsbjorke » 26 Sep 2015, 14:28

Hello all

Posting this as an easy solution to a problem that maybe others have too. It would be really useful if something similar was implemented.

My WiFi router (which my EasyESP sensors connect to) seems to reboot itself one or two times every 24 hours (haven't really looked into why and if it can be changed). The EasyESP automatically restores the WiFi connection to the router when it's back online. But the MQTT/mosquitto connection does not restore. I solved this by adding a few lines of code in the watchdog starting on line 374 in ESPEasy.ino (meaning it will run every 30 sec):

Code: Select all

 
 if (MQTTclient.connected()) {
  Serial.println("Mosquitto connetion ok.");
} else {
  Serial.println("Mosquitto disconneted. Trying to reconnect.");
  MQTTclient.disconnect();
  delay(1000);
  MQTTConnect();
}
In some situations it said mosquitto was disconnected, tried to reconnect and seemed to succeed, but on the next run it was still disconnected. Therefore i added the disconnect() wich seems to solve that problem. Also, don't know if the delay is really needed. But it seems to work!

Martinus

Re: Drops MQTT/mosquitto connection on wifi router reboot.

#2 Post by Martinus » 27 Sep 2015, 10:35

Thanks for testing and debugging! We will include it in the next release.

asm7100
Normal user
Posts: 96
Joined: 13 Sep 2015, 21:45
Location: Denmark

Re: Drops MQTT/mosquitto connection on wifi router reboot.

#3 Post by asm7100 » 27 Sep 2015, 22:36

How you set at ip to the mac add in your router?

A router renew the connection every 24 hours normal.
5xESP-01 - 3xESP-12 - 2xESP-12E 3xRPIb+ - 1xBPIm1 - 3xACTi DOME - 7xACTi Indoor cam. Lot off cisco equ.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests