Skip to content

ESP8266HTTPclient http.getstring() causing delays since version 2.5.1 #6501

Closed
@MacSass

Description

@MacSass

Basic Infos

  • [x ] I have read the documentation at readthedocs and the issue is not addressed there.
  • [x ] I have tested that the issue is present in current master branch (aka latest git).
  • [x ] I have searched the issue tracker for a similar issue.

Platform

  • Hardware: [ESP-12]
  • Core Version: [latest git]
  • Development Env: [Arduino IDE]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Nodemcu]
  • Flash Size: [4MB]
  • Upload Using: [SERIAL]

Problem Description

I have a fairly simple sketch that uses ESP8266HTTPClient to pull a XML from my AVM Fritz Box router. It downloads a challenge file that is needed in ongoing process to calculate a response and login to the router ...

Since core version 2.5.1 this single HTTP request takes 5000ms longer than with previous versions. In fact the http.getString() is what causes the 5000ms delay. Same code compiled with up to version 2.5.0 the same request only takes about 300ms.

This issue does not apply to all HTTP requests, pulling the same XML from my website, the additional 5000ms time delay is not seen.

Comparing version I found there was a change in honoring the http.timout delay and I suspect that the changes made cause the http.getstring() to wait for the timeout instead of coming back directly after the file has been read.
Honor timeout in HTTPClient #6056

Unfortunately I´m not savy enough to identify the exact issue. Also, as it does not apply to all http requests, I suspect it might only happen if the webserver does not send a standard C string with correct terminating characters.
As said - that is / was no issue up to version 2.5.0

I also tried to reduce the http.timout() to e.g. 1000ms, which reduced the overall time, but still http.getstring always has to wait for the timeout, which was not the case prior to version 2.5.1.

Sample Sketch

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char* ssid = "mySSID";
const char* password = "myWifiPassword";

HTTPClient http;

void setup() {
  Serial.begin(9600); 
  delay(10);
  if (WiFi.status() == WL_CONNECTED) {
    Serial.print("Already connected... IP address: ");
    Serial.println(WiFi.localIP());    
  } else {
    Serial.print("Connecting to ");
    Serial.println(ssid);
    WiFi.begin(ssid, password);
  
    while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
    } 
  } 
}

void loop() {
  Serial.println("Challenge: " + getSID());   
  delay(60 * 1000);
}

String getSID() {
  unsigned long startMillis;
  startMillis = millis(); 
  //http.setTimeout(1000);
  http.begin("http://fritz.box/login_sid.lua");
  int retCode = http.GET();
  if (retCode != 200) {
    Serial.println("Get Challengd failed! " + String(retCode));
    return "false";
  }
  String result = http.getString();  // <<-- this is taking 5000ms extra since version 2.5.1
  String challenge = result.substring(result.indexOf("<Challenge>") + 11, result.indexOf("<Challenge>") + 19);
  http.end();
  Serial.print("Challenge retrieval took: ");
  Serial.println(millis() - startMillis);
  return challenge;
}

If you require any more information, please let me know.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions