monstrenyatko / ArduinoMqtt

MQTT client for Arduino
MIT License
72 stars 12 forks source link

ESP32 Task-WDT make reboot in special situation [solved] #22

Closed srghafoori closed 3 years ago

srghafoori commented 3 years ago

Hi

In this situation Task-WDT reboot will occurred in ESP32 when we used RTOS:

Then when we are waiting for message ACK, Task-WDT may overflow (Depends on overflow time). To resolve the problem, we can add feed functions like vTaskDelay() somewhere in do while loop in waitFor() function or it's better add it to elapsedMs() function.

Thanks All

monstrenyatko commented 3 years ago

Hi @srghafoori, could you please provide more information. The library is platform-agnostic. You have to implement your own Network class including the connected() method. I have never used ESP32 and RTOS, the Task-WDT looks like a watchdog task, you should guarantee you do not block it.

If I understood correctly the problem with MqttClient.isConnected returning true when the connection is actually broken.

Try to collect more logs with with MQTT_LOG_ENABLED:

define MQTT_LOG_ENABLED                         1
srghafoori commented 3 years ago

Hi @monstrenyatko

Yes, this library is not under RTOS, I just wanted to say that if someone has similar conditions, they can use this solution. About MqttClient.isConnected it returns FALSE about 20 to 30 seconds after disconnection.

Good luck

monstrenyatko commented 3 years ago

@srghafoori, sorry if I miss something but I do not see the conditions in your original message. MqttClient.isConnected is true after successful connect call and till:

The MQTT protocol has no way to sense the disconnection until the next communication, you may need to adjust your keep-alive interval

srghafoori commented 3 years ago

Hi, @monstrenyatko Thanks for the tip