1

I'm trying to port my esp32 program to esp8266, and i've come across a problem where i can't get a response from a HTTPS GET request on esp8266, but on my esp32 the same code works fine. The function i'm using looks like this:

void GetHTTP()
{
  if (WiFi.status() == WL_CONNECTED)
  {
    HTTPClient http;
    http.begin(requestURL);
    int httpCode = http.GET();
    if (httpCode > 0)
    {
      requestData = http.getString();
      GenerateTable();
      //GetDelimiterCount(requestData, delimiterStart);
    }
    http.end();
  }
}

I've also tried running my request with the esp8266 "BasicHttpsClient" and "BasicHttpClient", and in both cases the program returns the error: "connection failed" from https.errorToString(httpCode).s_str() or http code "-1" without any API specific error codes.

I'm requesting from Trafiklab's realtime infromation v4 API And the request looks somewhat like this:

https://api.sl.se/api2/realtimedeparturesV4.json?

I've omitted the API key and parameters i use from this URL. The response is also correct when requested by any browser.

Could this be something to do with SSL? I'm completely out of clues as to what the differences between esp32's and esp8266's http-client libraries might be. I'm also using the latest version of the ESP8266 Boards libraries (2.7.4).

3
  • see the examples of the ESP8266HttpClient library
    – Juraj
    May 15 at 14:03
  • I did. I mentioned that in my initial post.
    – Boyfinn
    May 15 at 14:16
  • look again. focus on the first parameter of http.begin in BasicHttpsClient
    – Juraj
    May 15 at 15:48
0

I ended up using

ESP8266WiFi.h

instead of

ESP8266WiFiMulti.h

This fixed both my original code and the basic HTTPS example. I still don't understand what difference it made though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.