Repository navigation
Conversation
writeToStreamDataBlock() waited for the rest of a body for as long as connected() held. A server that stops sending part way through a body without closing the connection leaves connected() true, so getString() never returned and the unit stopped responding. Give up after _tcpTimeout without data and return HTTPC_ERROR_READ_TIMEOUT, as handleHeaderResponse() already does. Same fix as arendst/Tasmota#25139.
Author
|
For context, this came out of Sonoff-OTA, an over-the-air Sonoff S60 to Tasmota converter. The same stalled-download problem turned up in several other projects; the related pull requests, and how each fix was tested, are collected in docs/upstream-contributions.md. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HTTPClientLight::writeToStreamDataBlock()waits for the rest of a response body for as long asconnected()holds, with no time limit. If the server stops sending part way through a body without closing the connection (its computer sleeps, a cable is pulled, the network drops),connected()stays true andgetString()never returns.SendToHTTPwith "wait for ack", and anything else reading a reply throughHttpClientLight, then leaves the unit unresponsive until it is power-cycled.This gives up after
_tcpTimeoutwithout data and returnsHTTPC_ERROR_READ_TIMEOUT, ashandleHeaderResponse()already does for the headers. Each piece of data resets the clock, so a slow body still completes, andsetTimeout()still lets a caller wait longer.HttpClientLightcomes from Tasmota, where the same change was merged in arendst/Tasmota#25139. The body loop here was identical to Tasmota's before that change, so the patch is the same.Testing: a sketch using ESPEasy's
HttpClientLight(before and after this change) fetches each case from a test server fromloop()while serving a web page, on an emulated ESP32-C3 (QEMU, arduino-esp32 3.3.12):Content-Length, no length, chunked)writeToStream()-11Content-Length, server closes, chunked)setTimeout(10000)normal_ESP32c3_4M316kbuilds without warnings in this file.