adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support
MIT License
566 stars 292 forks source link

ESP32 won't reconnect to wifi after disconnecting #209

Closed JnthnWJ closed 2 years ago

JnthnWJ commented 2 years ago

I was sent here from the Adafruit forms: https://forums.adafruit.com/viewtopic.php?f=56&t=188562&p=913394#p913394

When the ESP32 disconnects from the Wi-Fi, despite successfully reconnecting, it is not able to resume uploading to Adafruit IO. I'm testing it with an iPhone hotspot, so I can cycle the Wi-Fi and clearly see when it reconnects. This problem persists not only across the code I've written but in the sample code as well. I also ran the same code on an ESP8266 and it had no problem resuming uploading after disconnecting and reconnecting to the Wi-Fi.

Here is one of the sample sketches I tried during testing: https://github.com/adafruit/Adafruit_MQTT_Library/blob/master/examples/adafruitio_secure_esp32/adafruitio_secure_esp32.ino

brentru commented 2 years ago

This sketch does not handle reconnecting to the WiFi network, it only handles reconnecting to the MQTT server as described in the comment and function name. Reconnecting to WiFi is out of the scope of this example.

// Function to connect and reconnect as necessary to the MQTT server.
MQTT_connect()