Hello,
I am currently trying to connect to an https webserver via mbed-http.
Unfortunately, I am encountering the error that my HTTPS request returns an NSAPI_ERROR_NO_CONNECTION (-3004) error. If I change the URL to the IP of the webserver, the error changes to NSAPI_ERROR_AUTH_FAILURE] (-3011), this is my code:
std::string http_request_str(staging_backend_url);
http_request_str.append(endpoint).append(api_key);
printf("HTTP Request String: %s\r\n", http_request_str.c_str());
HttpRequestBase *get_req;
if(https) {
get_req = new HttpsRequest(network, tls_certificates, HTTP_GET, http_request_str.c_str());
} else {
get_req = new HttpRequest(network, HTTP_GET, http_request_str.c_str());
}
HttpResponse *get_res = get_req->send();
if (!get_res) {
printf("HttpRequest failed with error code %d\r\n", get_req->get_error());
return false;
}
To me it looks like that mbed-os is unable to resolve the URL. The second problem is that the webservice is behind Cloudflare which is probably the reason why direct IP accesses don’t work.
Any ideas how to fix this?