knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.83k stars 1.47k forks source link

MQTT connect function hangs the code for certain time if there is no internet #402

Open romuye123 opened 6 years ago

romuye123 commented 6 years ago

Hi @knolleary , The following function

pubsubclient.connect(clientId.c_str(),mqtt_username,mqtt_password);

blocks the program for few seconds( atleast 5seconds in my program) and then says mqtt connect failed, if the ESP is CONNECTED to WIFI but there is NO INTERNET.

NOTE: MQTT broker is on my server. Any workaround to reduce this time ? or make it non blocking ?

knolleary commented 6 years ago

If you search the issue list you'll see this question asked quite a few times.

The delay is coming from the underlying network client. I am not aware of any workaround.