bertmelis / espMqttClient

MQTT 3.1.1 client library for the Espressif devices ESP8266 and ESP32 on the Arduino framework.
https://www.emelis.net/espMqttClient/
MIT License
100 stars 21 forks source link

[BUG] ESP32 with espMqttClient crashes with heavily Network traffic #153

Closed knickohr closed 4 months ago

knickohr commented 4 months ago

Which platform, esp8266 or esp32? Do you use TLS or not? No Do you use an IDE (Arduino, Platformio...)? Which version of the Arduino framework? Latest

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

We using this lib with AhoyDTU. Ahoy has a lot of single topics. In my case with 16 inverters over 1000. so far so good, but if I have much other network traffic the ESP crashes if MQTT is enabled. Nothing happens without other network activity except MQTT.

I can reproduce this every time. Publish a lot of sigle topics in a short time. Make parallel heavy network traffic, maybe downloading or moving really big files. Broker (local mosquitto on a raspi) disconnects and bΓ€m πŸ’₯ reboot of the ESP.

If I do this without MQTT, nothing happens too, no reboot.

bertmelis commented 4 months ago

I really want to investigate the issue, but you need to give me a bit more info.

I don't need a full main.cpp but some code is handy. If you have a crashlog (backtrack), please decode and share.

knickohr commented 4 months ago

The Complete Code is here :

https://github.com/lumapu/ahoy/tree/development03/src

Use the dev branch, not the main. Main is way ahead the dev, but still dev πŸ˜‰

Sorry, I don’t have crashlog.

bertmelis commented 4 months ago

Would it be possible to have a crashlog? I don't even know where to start looking for a bug.

knickohr commented 4 months ago

message-3 2.txt

bertmelis commented 4 months ago

StoreProhibitedCause means your writing to memory that is not available Crashed task handle: 0x3ffbd4d4: I don't know which task that is. It's not the MQTT task nor the Arduino setup/loop task.

This isn't going to be an easy search...

bertmelis commented 4 months ago

I suspect a concurrency issue here: https://github.com/bertmelis/espMqttClient/blob/main/src/MqttClient.cpp#L326

bertmelis commented 4 months ago

Is it possible to test the code in the PR?

I did a fairly intensive but limited test with an ESP32-S3 (Arduino core 3.0) to see if the fixed actually works. I'd love to hear your feedback.

knickohr commented 4 months ago

Merged & testing πŸ‘

knickohr commented 4 months ago

Works great for my Setup. Uptime 40 hours and running πŸ‘

πŸ™‡

Thx a lot 😎

bertmelis commented 4 months ago

I'll do some more testing on my site (async) and merge/release soon.