knolleary / pubsubclient

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

fix: connect failed - no CPU time for IP stack #1050

Open devmirek opened 3 months ago

devmirek commented 3 months ago

ESP32-C3 is not able to receive CONNACK packet because the waiting loop did not have any delay to let other tasks to process incoming TCP packet data.

EmbeddedDevver commented 2 months ago

Better use yield(). Also same as #567 and #901

devmirek commented 2 months ago

Better use yield(). Also same as #567 and #901

I would prefer yield() as well. I have tested it with yield() first. It didn't work. Small delay was the only option that reliably solved it (ESP32-C3 with WiFiClientSecure). It was a very tricky issue because sometimes it was successfully reconnected (CONNACK was received after reconnection) but the first connect always failed and sometimes the next reconnects randomly failed as well - always due to CONNACK timeout.