ESP8266 Developer Zone The Official ESP8266 Forum 2021-04-23T15:09:42+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=74437 2021-04-23T15:09:42+08:00 2021-04-23T15:09:42+08:00 https://bbs.espressif.com:443/viewtopic.php?t=74437&p=99695#p99695 <![CDATA[Re: esp_http_client returns error (cant connect)]]> As I am not providing the certificate in the config (because I dont need to verify the server), the connection fails. This should be solved by setting "CONFIG_ESP_TLS_INSECURE" in the MENUCONFIG, but this option is missing (see attachment).
img.jpg

Statistics: Posted by janav1 — Fri Apr 23, 2021 3:09 pm


]]>
2021-04-22T17:58:37+08:00 2021-04-22T17:58:37+08:00 https://bbs.espressif.com:443/viewtopic.php?t=74437&p=99690#p99690 <![CDATA[Re: esp_http_client returns error (cant connect)]]> Statistics: Posted by Her Mary — Thu Apr 22, 2021 5:58 pm


]]>
2020-12-29T16:32:59+08:00 2020-12-29T16:32:59+08:00 https://bbs.espressif.com:443/viewtopic.php?t=74437&p=99090#p99090 <![CDATA[esp_http_client returns error (cant connect)]]> 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:

<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:

esp_http_client_config_t config = {
            .host = "https://www.howsmyssl.com",
            .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));
      }
      esp_http_client_cleanup(client);
      


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

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

Statistics: Posted by janav1 — Tue Dec 29, 2020 4:32 pm


]]>