khoih-prog / Portenta_H7_AsyncWebServer

Asynchronous WebServer Library for STM32H7-based Portenta_H7 using mbed_portenta core. This library, which is relied on Portenta_H7_AsyncTCP, is part of a series of advanced Async libraries, such as AsyncTCP, AsyncUDP, AsyncWebSockets, AsyncHTTPRequest, AsyncHTTPSRequest, etc. Now supporting using CString in optional SDRAM to save heap to send very large data
GNU Lesser General Public License v3.0
12 stars 3 forks source link

Mqtt and Async Webserver can't co-exsist. #15

Closed javos65 closed 1 year ago

javos65 commented 1 year ago

Describe the bug

Combining the Wifi MQTT and the Async Webserver example results in crashed OS (red leds blinking)

Code : https://github.com/javos65/AsyncWebServer_plus_MQTT

Expected behavior

Should co-exsist ?

Actual behavior

Mbed OS crashes as soon as Webserver is approached by http-get call : Red leds flashing.

Screenshots

n.a.

Information

Arduino IDE 1.8.18 Arduino IDE 2.0 Portenta H7 rev2 lib Portenta_H7_AsyncWebServer 1.4.2 lib Portenta_H7_AsyncTCP 1.4.0 lib PubSubClient V2.8 ---> should we use another PubSub ???

khoih-prog commented 1 year ago

Hi @javos65

Unless you can prove there is a real bug of the library, I'm closing the issue because I don't have time to investigate what's wrong with your code. It's your job to learn why and fix it.

Good programmer is not just sitting passively, relying on other people, when getting into fatal crash. We all can learn a lot from the mistake / experience. I'd appreciate if you can share yours back here what's wrong. If it turns out to be this library's bug, we're happier to find out and fix.

Good Luck,

khoih-prog commented 1 year ago

FYI, try the

https://github.com/khoih-prog/Portenta_H7_AsyncWebServer/blob/66c99614c6d98e69817064de3f06ae9afa23b015/examples/Ethernet/MQTTClient_Basic/MQTTClient_Basic.ino#L32

https://github.com/khoih-prog/Portenta_H7_AsyncWebServer/blob/66c99614c6d98e69817064de3f06ae9afa23b015/examples/Ethernet/MQTTClient_Auth/MQTTClient_Auth.ino#L31

javos65 commented 1 year ago

Thanks for the reply. The used MQTT calls are a 1:1 copy of your MQTTClient_Basic.ino example, same for the Async_AdvancedWebServer.ino example. Seperate sketches work fine. My example is your 2 example-code combined in one sketch, and combined in one sketch it fails on Mbed OS / Portenta H7.

You dont need to look or debug my code, however if you can show a working combination of the Async_AdvancedWebServer and PubSubClient in one sketch, that would be appreciated (Probably 15 minutes of work to combine you own examples ?)

khoih-prog commented 1 year ago

I don't like and have interest to do that.

Just a suggestion for you

  1. Async is better working with Async. The examples are just simple demo to show basic usage and don't fully rely on them in your use cases.
  2. Use AsyncMQTT_Generic library, such as these examples as the starting point to merge

You'll sure be much better if successful then.

Good Luck,

javos65 commented 1 year ago

This is the right direction - thanks. AsyncMQTT_Generic is combinable with the Portenta_H7_AsyncWebServer libraries, and seems to work in co-exsistance. Async is definitely not advisable with the legacy PubSubClient libraries.

Regards - Jay