-->
Page 1 of 1

http.getString returns empty string since update

PostPosted: Mon Jul 27, 2020 7:43 am
by beejayf
I have a very simple sketch that worked fine with ESP8266 board version 2.7.1 - but with 2.7.2 it just returns an empty string

Code: Select all#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
 
const char* ssid = "mynet";
const char* password = "mypwd";
 
void setup () {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
 
    delay(1000);
    Serial.print("Connecting..");
  }
}
 
void loop() {
  Serial.println("Connected..");
  if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
 
    HTTPClient http;  //Declare an object of class HTTPClient
 
    http.begin("http://192.168.10.101/temp");  //Specify request destination
    int httpCode = http.GET();                                                                  //Send the request
    Serial.print("htcode: "); 
    Serial.println(httpCode);
    if (httpCode > 0) { //Check the returning code
 
    String payload = http.getString();   //Get the request response payload
    Serial.print("###");
    Serial.print(payload);                     //Print the response payload
    Serial.println("###");
  }
 
  http.end();   //Close connection
 
}
 
delay(30000);    //Send a request every 30 seconds
 
}


This happened on a NodeMCU ESP-12E with the latest Adruino IDE (1.8.13 - Windows 10 Install (not the store version - if this is important) - since this is the only type I have right now, I cannot check it on different hardware. I tried two PCs - same result.

once I roll back to 2.7.1 it works - back to 2.7.2: empty string.

Am I doing something wrong or is this a bug in the latest release?

Re: http.getString returns empty string since update

PostPosted: Mon Jul 27, 2020 1:01 pm
by pangolin
Have you searched the ESP8266 core github or reported the issue there? I'm sure you will get a much more informed response "straight from the horses mouth"

Re: http.getString returns empty string since update

PostPosted: Fri Dec 04, 2020 1:10 pm
by VladG
Hi, Was this issue addressed? I'm having the same issue when the response from the server is long.

Re: http.getString returns empty string since update

PostPosted: Sat Apr 17, 2021 1:39 pm
by WilliansBR
beejayf wrote:I have a very simple sketch that worked fine with ESP8266 board version 2.7.1 - but with 2.7.2 it just returns an empty string

This happened on a NodeMCU ESP-12E with the latest Adruino IDE (1.8.13 - Windows 10 Install (not the store version - if this is important) - since this is the only type I have right now, I cannot check it on different hardware. I tried two PCs - same result.

once I roll back to 2.7.1 it works - back to 2.7.2: empty string.

Am I doing something wrong or is this a bug in the latest release?





For me with 8266 version 2.7.4 the "http.getString" returns empty too. I downgrade to 2.7.1 and the sketch works very well. Thanks for mention this on your doubt!!!