esp_http_client returns error (cant connect)

Posts: 1
Joined: Wed Dec 09, 2020 2:45 pm

esp_http_client returns error (cant connect)

Postby janav1 » Tue Dec 29, 2020 4:32 pm

I am trying to use esp_http_client with ESP8266 RTOS SDK v3.3 to perform HTTP POST using TLS, but the library fails with error:

Code: Select all

<ESC>[0;31mE (127251) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x4c<ESC>[0m<CR><LF>
<ESC>[0;31mE (127255) esp-tls: Failed to open new connection<ESC>[0m<CR><LF>
<ESC>[0;31mE (127258) TRANS_SSL: Failed to open a new connection<ESC>[0m<CR><LF>
<ESC>[0;31mE (127269) HTTP_CLIENT: Connection failed, sock < 0<ESC>[0m<CR><LF>
<ESC>[0;31mE (127274) HTTPS: Error perform http request ESP_ERR_HTTP_CONNECT<ESC>[0m<CR><LF>

code to reproduce the error (_http_event_handler is the default one provided in examples):

Code: Select all

esp_http_client_config_t config = {
            .host = "",
            .path = "/a/check",
            .transport_type = HTTP_TRANSPORT_OVER_SSL,
            .event_handler = _http_event_handler,
      esp_http_client_handle_t client = esp_http_client_init(&config);
      esp_err_t err = esp_http_client_perform(client);
      if (err == ESP_OK) {
         int sc = esp_http_client_get_status_code(client);
         ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %d", sc, esp_http_client_get_content_length(client));
         if(sc == 200){
            esp_http_client_read_response(client, post_data, 512);
      } else {
         ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err));

Has anyone encountered the same problem? How to solve it?

Edit 1: Since no one has responded yet, should I assume that the http_client library works for everyone?

Her Mary
Posts: 488
Joined: Mon Oct 27, 2014 11:09 am

Re: esp_http_client returns error (cant connect)

Postby Her Mary » Thu Apr 22, 2021 5:58 pm

The latest RTOS 3.4 is released recently, maybe you could have a try to see if the issue persists?

Who is online

Users browsing this forum: No registered users and 15 guests