I'm using ESP8266-7 as the only micocontroller in my project and I have a tiny problem with it. there are sometimes that the internet line is broken and my ESP tries to reconnect to the broker. while this happens, the program freezes until the internet gets back online and ESP reconnects to the broker. (in more specific way, my program waits 15 seconds in .connect(device_ID.c_str(), mqtt_user.c_str(), mqtt_pass.c_str())
every time.)
I'm using PubSubClient.h
library and as I have tested, this problem occurs when I call mqtt_client.connect(device_ID.c_str(), mqtt_user.c_str(), mqtt_pass.c_str())
. this way the program runs this function and waits till the process finishes. this may take up to 15 seconds.
how can I try to connect to the broker, without using this code or is there any other solution for me in which my program does not freezes?
can ESP connects to the broker in the background while my program is still running?