mathieucarbou / ESPAsyncWebServer

Asynchronous HTTP and WebSocket Server Library for ESP32, ESP8266 and RP2040
https://mathieu.carbou.me/ESPAsyncWebServer/
GNU Lesser General Public License v3.0
92 stars 17 forks source link

Watchdog in AsyncTCP when sending very long chunked response #164

Closed Levak closed 21 hours ago

Levak commented 21 hours ago

Hi there!

Description

When the ESPAsyncWebServer sends a very long chunked response (over 30 seconds), the ESP32 crashes on a watchdog timeout in AsyncTCP. I can see in Chrome DevTools that the chunked answer is being sent correctly, one chunk at a time, but when the 30 seconds mark hits, the ESP32 resets.

In my code, I am trying to traverse a list of files from an SD card. After roughly 300 files (700 in this particular test) sent, aka 30 seconds, the problem appears. Pagination can be implemented, but we are trying to stay retro-compatible with an official WebUI that lacks such feature. This is sadly a regression compared to a basic WebServer app, where the timeout can be as long as one wants, as long as the client doesn't disconnect.

Link: https://github.com/Levak/sdwifi/blob/async/sdwifi.ino#L714

Board: esp32-pico-d4 (Fysetc SD WIFI PRO)

Stack trace

E (809882) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time: E (809882) task_wdt: - async_tcp (CPU 0/1) E (809882) task_wdt: Tasks currently running: E (809882) task_wdt: CPU 0: IDLE0 E (809882) task_wdt: CPU 1: loopTask

Additional notes

Old discussion about this code

mathieucarbou commented 21 hours ago

That's not a bug, that is exactly what is expected.

You need to design you code to work another way, or use SSE or websockets.