-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTPUpdate read Timeout #9823
Comments
I'm sure the server and the url is working fine since I can download the firmware directly. The network is fast and reliable, I have tested it. |
Okay so i have modified the http timeout to 30000 in
|
Need a way to set the timeout from outside the HttpUpdate class |
HTTPUpdate Updater(30000); |
I get a bunch of errors when using this
|
This compiles fine here. Check for issues in your code. #include "HTTPUpdate.h"
HTTPUpdate Updater(30000);
void setup() {
Updater.rebootOnUpdate(false);
Updater.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
Updater.onStart([]() {});
Updater.onEnd([]() {});
Updater.onError([](int err) {});
Updater.onProgress([](int current, int total) {});
}
void loop() {
} |
Is this 2.0.17? |
3.0.1 |
Yeah, so it does not work on 2.0.17. I got this error again even when my modification is there. HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& currentVersion, bool spiffs, HTTPUpdateRequestCB requestCB)
{
HTTPUpdateResult ret = HTTP_UPDATE_FAILED;
// use HTTP/1.0 for update since the update handler not support any transfer Encoding
http.useHTTP10(true);
http.setTimeout(60000); // <--- ADDED THIS LINE
http.setFollowRedirects(_followRedirects);
http.setUserAgent("ESP32-http-Update");
http.addHeader("Cache-Control", "no-cache");
http.addHeader("x-ESP32-STA-MAC", WiFi.macAddress());
http.addHeader("x-ESP32-AP-MAC", WiFi.softAPmacAddress());
http.addHeader("x-ESP32-free-space", String(ESP.getFreeSketchSpace()));
http.addHeader("x-ESP32-sketch-size", String(ESP.getSketchSize()));
String sketchMD5 = ESP.getSketchMD5();
... I got read timeout after 30 sec and I can't do anything about it. |
in version 2 the timeouts were no set and used correctly on WiFiClient. WiFiClient::setTimeout was hiding Stream::setTimeout used for readBytes in HTTPClient |
I have also set it like this WiFiClientSecure secureClient;
secureClient.setTimeout(35); And I have modified from this /*
Init read&timeout counters and try to read, if read failed, increase counter,
wait 100ms and try to read again. If counter > 300 (30 sec), give up/abort
*/
toRead = 0;
timeout_failures = 0;
while(!toRead) {
toRead = data.readBytes(_buffer + _bufferLen, bytesToRead);
if(toRead == 0) {
timeout_failures++;
if (timeout_failures >= 300) {
_abort(UPDATE_ERROR_STREAM);
return written;
}
delay(100);
}
} to this /*
Init read&timeout counters and try to read, if read failed, increase counter,
wait 100ms and try to read again. If counter > 300 (30 sec), give up/abort
*/
toRead = 0;
timeout_failures = 0;
while(!toRead) {
toRead = data.readBytes(_buffer + _bufferLen, bytesToRead);
if(toRead == 0) {
timeout_failures++;
if (timeout_failures >= 1300) {
_abort(UPDATE_ERROR_STREAM);
return written;
}
delay(100);
}
} Without success. |
I see this in int Stream::timedRead()
{
int c;
_startMillis = millis();
do {
c = read();
if(c >= 0) {
return c;
}
} while(millis() - _startMillis < _timeout);
return -1; // -1 indicates timeout
} Should I modify |
Board
ESP32-Wrover
Device Description
Hardware Configuration
Version
v2.0.17
IDE Name
PlatformIO
Operating System
Windows10
Flash frequency
80
PSRAM enabled
yes
Upload speed
115200
Description
I want to perform a HTTPUpdate which was working fine before but suddenly I got read Timeout.
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: