espMqttClient: [BUG] Reconnect does not work if broker is completely unavailable

Do not use to discuss topics!

Describe the bug With the newer library versions 1.4.0 and 1.4.1 reconnect does not work in all cases.

Which platform, esp8266 or esp32?

  • ESP32 and ESP8266
  • no TLS
  • VSCode + PlatfromIO

Please include any debug output and/or decoded stack trace if applicable.

Expected behaviour MqTT reconnects after broker comes back online. This works with library version 1.3.3

To Reproduce I use ioBroker with MqTT adapter as broker.

  1. If I stop the adapter reconnect works fine (the IP of the broker is still available and ping will be possible).
  2. If I completely shut down ioBroker (ping not possible) the MqTT client does not reconnect after starting ioBroker again
  3. The problem is caused by the following new code section:

Example code affected code https://github.com/bertmelis/espMqttClient/blob/15041c47f6cdec7047dbee28acd63868039cc0a7/src/MqttClient.cpp#L223-L234

if EMC_WAIT_FOR_CONNACK isn’t defined the reconnect works fine.

Additional context EMC_WAIT_FOR_CONNACK needs to be undefined as workaround

This does not work: #define EMC_WAIT_FOR_CONNACK 0 before #include <espMqttClient.h>

this works as expected compile flag in platformio.ini -DEMC_WAIT_FOR_CONNACK=0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I’ll push a new release, as soon Github is back up.

Thank you again. Just tesed with the new release 1.4.2. It worked like a charm.

never saw such a rapid development before! Congratulations, this is how github works =)

tried with -DDEBUG_ESP_MQTT_CLIENT -DDEBUG_LEVEL=DBG_DEBUG but no different output.

Yes somethings is really strange with github - can’t delete my duplicate comments … don’t know where they came from.

I see that behavoir with 1.4.[0|1], too. Would be great if you find that issue. @lumapu: Keep up your great work on Ahoy, I use it since the first versions and it has made great progress.