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:
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).
http.begin
in BasicHttpsClient