Page 1 of 1

reconnect timeout

PostPosted: Wed Sep 30, 2020 6:47 am
by Masoud Navidi
hi everyone
I'm using ESP8266-7 as the only micocontroller in my project and I have a tiny problem it. there is some times that the internet line is broken and my ESP tries to reconnect to the broker. while this happens, the program freezes until the internet get back online and ESP reconnects to the broker.
I'm using
Code: Select allPubSubClient.h
library and as I have tested, this problem occurs when I call
Code: Select allmqtt_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?
can ESP connects to the broker in the background while my program is still running?