Repository navigation
AsyncAbstractResponse truncates 85 octets in the non-empty segment #315
Description
Activity
It's a bug indeed, I'll take it.
Reacted by Mathieu Carbou- addedType: BugSomething isn't workingSomething isn't workingand removed
on Oct 18, 2025 @vortigont I agree...
Line 448 of WebResponse.cpp maybe ?
Reacted by Junxiao Shi- added a commit that references this issue
on Oct 19, 2025 @yoursunny thanks for the report, nice catch! Pls check the fix, it works for me for you cam project.
NOTE:
you should not do thisThe first call returns RESPONSE_TRY_AGAIN, it would delay you data transfer for 1 RTT at least.P.S. unfortunately this AbstractResponse is not the best fit for sending large chunks of data due to intermediate buffering. If you are interested in a way more efficient approach to use AsyncServer for cam streaming you can check for my recent experimental websocks in #312. There is an example specifically made for esp32 cam, it works much better with less memory footprint even without a dedicated RTOS task to run a cam.
- added a commit that references this issue
on Oct 19, 2025 @yoursunny @vortigont : FYI I added an example in the project to show how to send large responses:
Sadly I am not able to reproduce the problem through these examples and with the code in main.
Is one of you capable of that (using main branch) ? If yes, could you please share your MRE ?
yes, it reproduces easily with esp32-cam, and works fine with my fix.
Will try to play with your minimal example, @mathieucarbou, must be some corner caseReacted by Mathieu Carbou- added 2 commits that reference this issue
on Oct 19, 2025 - added 3 commits that reference this issue
on Oct 23, 2025 - added 5 commits that reference this issue
on Oct 27, 2025
Platform
ESP32
IDE / Tooling
Arduino (IDE/CLI)
Versions
esp32 v3.3.2
Async TCP v3.4.9
ESP Async WebServer v3.8.1
What happened?
My sketch uses a
AsyncAbstractResponsesubclass where_sendContentLengthis disabled and the_fillBufferfunction has the following behavior:RESPONSE_TRY_AGAIN.buflen.buflen.0to end the response.With the sketch running on either ESP32 or ESP32C3, I invoke
wgetcommand to trigger the handler.Downloaded file: 1.txt
The console log pasted below indicates that the sketch has filled 5760 "B"s and 4308 "C"s in the response.
However, the downloaded file has 5675 "B"s and 4308 "C"s.
In other words, 85 octets are truncated off the buffer filled in the second call.
Stack Trace
Wireshark packet trace: 1.pcapng.gz
It may or may not be a coincidence, but I noticed:
buflenpassed to the first_fillBuffercall is 85 larger than thebuflenpassed to the second_fillBuffercall.Minimal Reproductible Example (MRE)
I confirm that: