me-no-dev / ESPAsyncWebServer

Async Web Server for ESP8266 and ESP32
3.8k stars 1.23k forks source link

Deadlock when Serving Static Files with ESP32AsyncWebServer Library #1450

Open corke2013 opened 4 days ago

corke2013 commented 4 days ago

Hi :wave:

I'm encountering an issue while trying to serve static files using the ESP32AsyncWebServer library. Specifically, I see the following error message:

E (18862) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: 
E (18862) task_wdt:  - async_tcp (CPU 0/1)

TL;DR:

It appears there's a deadlock between the async_tcp and tiT threads when the _async_queue (located here) becomes full. This causes the watchdog timer to be triggered. More details about why this happens can be found here.

Possible Workaround:

Some users have suggested increasing the size of _async_queue (from the default 32 to values like 64, 128, or even 512). While this can alleviate the issue in some cases, I don't believe it's a reliable long-term fix, as the underlying deadlock bug still persists.

Suggested Solution:

In my testing, using the AsyncTCPSock library has successfully resolved the deadlock issue without introducing compatibility problems with ESPAsyncWebServer. More on this fix can be found in this comment.

Given that ESPAsyncWebServer is the go-to async web server library for ESP32, I propose that we replace AsyncTCP with AsyncTCPSock to eliminate the deadlock issue once and for all.

I've had limited testing with AsyncTCPSock, but it works well in my setup.

Looking forward to your thoughts!