Closed
Description
If I turn off the Mosquitto broker and start it again, the Mega2560-client will not reconnect. The ESP8266 reconnects without a problem.
To be able to reconnect I had to add a 'disconnect' into the connection loop. Now my code looks like this:
void mqConnect() {
uint8_t loops = 0;
while (!mq.connect(MQTT_CLIENTID, MQTT_USERNAME, MQTT_KEY)) {
Serial.print('.');
if (++loops >= 2)
return;
delay(200);
mq.disconnect();
}
Serial.print("\nConnected to mqtt-broker\n");
...
On the ESP8266, if I run 'disconnect' without being connected, it reboots.
I have all work-arounds I need now, but it would of course be nice to other beginners if this could be handled by the library.
Metadata
Metadata
Assignees
Labels
No labels