esp-tls: Failed to connnect to host (errno 113)

luisfynn
Posts: 10
Joined: Fri Feb 25, 2022 9:26 am

esp-tls: Failed to connnect to host (errno 113)

Postby luisfynn » Thu Dec 22, 2022 12:10 am

I test http post send using wifi

I connect WIFI-A device and http post send. continuosly I try to connect WIFI-B device and http post send but it always fail.
all of wifi connection is success.

-this is error log
E (702663) esp-tls: Failed to connnect to host (errno 113)
E (702663) esp-tls: Failed to open new connection
E (702663) TRANS_SSL: Failed to open a new connection
E (702663) HTTP_CLIENT: Connection failed, sock < 0

I usu ESP-IDF V4.3.2

I need your help.

-this is my code (skip wifi connection)
  1. vTaskDelay(100);
  2.  
  3. esp_http_client_config_t config = {
  4.     .host = "log.bodyfriend.co.kr",
  5.     .path = "/api/product/history/create",
  6.     .transport_type = HTTP_TRANSPORT_OVER_SSL,
  7.     .event_handler = http_event_handler,
  8.     .cert_pem = bf_ca_pem_start,
  9.     .timeout_ms = INT32_MAX,
  10.     //.is_async = FALSE,
  11.     //.buffer_size = 4096,
  12. }; 
  13.  
  14. WIFI_Total_client = esp_http_client_init(&config);
  15.  
  16. if(WIFI_Total_client == NULL){
  17.     ESP_LOGI(TAG, "[%s]WIFI_Total_client is NULL", __func__);
  18. }else{
  19.     ESP_LOGI(TAG, "[%s]WIFI_Total_client isn't NULL", __func__);
  20. }
  21.  
  22. esp_err_t err = esp_http_client_set_method(WIFI_Total_client, HTTP_METHOD_POST);
  23. ESP_LOGI(TAG, "[%s]esp_http_client_set_method error code: %d", __func__, err);
  24.  
  25. err = esp_http_client_set_header(WIFI_Total_client, "Content-Type", "application/json");
  26. ESP_LOGI(TAG, "[%s]esp_http_client_set_header Content-Type error code: %d", __func__, err);
  27.  
  28. err = esp_http_client_set_header(WIFI_Total_client, "secretKey", "0a98shdfpa98h3r3r9f82h93hrjshdf8a7gsdjxv");
  29. ESP_LOGI(TAG, "[%s]esp_http_client_set_header secretKey error code: %d", __func__, err);
  30.  
  31. err = esp_http_client_set_post_field(WIFI_Total_client, data, strlen(data));
  32. ESP_LOGI(TAG, "[%s]esp_http_client_set_post_field error code: %d, data: %s", __func__, err, data);
  33.  
  34. esp_err_t result = ESP_FAIL;
  35.  
  36. result = esp_http_client_perform(WIFI_Total_client);
  37. ESP_LOGI(TAG, "[%s]http_client_send perform: %d", __func__, result);
  38.  
  39. if (result == ESP_OK) {
  40.     ESP_LOGI(TAG, "[%s]HTTP POST Status = %d, content_length = %d", __func__,
  41.     esp_http_client_get_status_code(WIFI_Total_client),
  42.     esp_http_client_get_content_length(WIFI_Total_client));
  43. } else {
  44.     ESP_LOGE(TAG, "[%s]http_client_send(\n HTTP POST request failed: %s", __func__, esp_err_to_name(result));
  45. }
  46.  
  47. //esp_http_client_close(WIFI_Total_client);
  48. //ESP_LOGI(TAG, "[%s]esp_http_client_close error code: %d", __func__, err);
  49.  
  50. err = esp_http_client_cleanup(WIFI_Total_client);
  51. ESP_LOGI(TAG, "[%s]esp_http_client_cleanup error code: %d", __func__, err);

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: esp-tls: Failed to connnect to host (errno 113)

Postby ESP_YJM » Thu Dec 22, 2022 9:59 am

Errno 113 generally is due to TCP SYN we sent with no response. You can use PC to connect WIFI-B and check whther TCP connection can be success.

luisfynn
Posts: 10
Joined: Fri Feb 25, 2022 9:26 am

Re: esp-tls: Failed to connnect to host (errno 113)

Postby luisfynn » Fri Dec 23, 2022 1:34 am

ESP_YJM wrote:
Thu Dec 22, 2022 9:59 am
Errno 113 generally is due to TCP SYN we sent with no response. You can use PC to connect WIFI-B and check whther TCP connection can be success.
PC is ok. What can I do to solve this problem???

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: esp-tls: Failed to connnect to host (errno 113)

Postby ESP_YJM » Fri Dec 23, 2022 3:47 am

Could you please enable DNS_DEBUG and TCP_DEBUG in lwip to check. Or could you please capture the air packet to see the DNS flow and TCP flow.

luisfynn
Posts: 10
Joined: Fri Feb 25, 2022 9:26 am

Re: esp-tls: Failed to connnect to host (errno 113)

Postby luisfynn » Fri Dec 23, 2022 5:03 am

ESP_YJM wrote:
Fri Dec 23, 2022 3:47 am
Could you please enable DNS_DEBUG and TCP_DEBUG in lwip to check. Or could you please capture the air packet to see the DNS flow and TCP flow.

Code: Select all

static esp_err_t esp_tcp_connect(const char *host, int hostlen, int port, int *sockfd, const esp_tls_t *tls, const esp_tls_cfg_t *cfg)
{
    esp_err_t ret;
    struct addrinfo *addrinfo;
    if ((ret = resolve_host_name(host, hostlen, &addrinfo)) != ESP_OK) {
        return ret;
    }

    int fd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol);
    if (fd < 0) {
        ESP_LOGE(TAG, "Failed to create socket (family %d socktype %d protocol %d)", addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol);
        ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_SYSTEM, errno);
        ret = ESP_ERR_ESP_TLS_CANNOT_CREATE_SOCKET;
        goto err_freeaddr;
    }

    void *addr_ptr;
    if (addrinfo->ai_family == AF_INET) {
		ESP_LOGW(TAG, "addrinfo->ai_family == AF_INET");
        struct sockaddr_in *p = (struct sockaddr_in *)addrinfo->ai_addr;
        p->sin_port = htons(port);
        addr_ptr = p;
    }
#if CONFIG_LWIP_IPV6
    else if (addrinfo->ai_family == AF_INET6) {
		ESP_LOGW(TAG, "addrinfo->ai_family == AF_INET6");
        struct sockaddr_in6 *p = (struct sockaddr_in6 *)addrinfo->ai_addr;
        p->sin6_port = htons(port);
        p->sin6_family = AF_INET6;
		ESP_LOGW(TAG, "p->sin6_port %d,  p->sin6_family %d", p->sin6_port,  p->sin6_family);
        addr_ptr = p;
    }
#endif
    else {
        ESP_LOGE(TAG, "Unsupported protocol family %d", addrinfo->ai_family);
        ret = ESP_ERR_ESP_TLS_UNSUPPORTED_PROTOCOL_FAMILY;
        goto err_freesocket;
    }

    if (cfg) {
        if (cfg->timeout_ms >= 0) {
            struct timeval tv;
            ms_to_timeval(cfg->timeout_ms, &tv);
            setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
            setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
            if (cfg->keep_alive_cfg && cfg->keep_alive_cfg->keep_alive_enable) {
                if (esp_tls_tcp_enable_keep_alive(fd, cfg->keep_alive_cfg) < 0) {
                    ESP_LOGE(TAG, "Error setting keep-alive");
                    goto err_freesocket;
                }
            }
        }
        if (cfg->non_block) {
            int flags = fcntl(fd, F_GETFL, 0);
            ret = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
            if (ret < 0) {
                ESP_LOGE(TAG, "Failed to configure the socket as non-blocking (errno %d)", errno);
                goto err_freesocket;
            }
        }
    }

	ESP_LOGW(TAG, "[%s]fd %d addrinfo->ai_addrlen %d", __func__, fd, addrinfo->ai_addrlen);

    ret = connect(fd, addr_ptr, addrinfo->ai_addrlen);
    if (ret < 0 && !(errno == EINPROGRESS && cfg && cfg->non_block)) {

        ESP_LOGE(TAG, "[%s]Failed to connnect to host (errno %d) (ret %d)", __func__, errno, ret);
        ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_SYSTEM, errno);
        ret = ESP_ERR_ESP_TLS_FAILED_CONNECT_TO_HOST;
        goto err_freesocket;
    }

    *sockfd = fd;
    freeaddrinfo(addrinfo);
    return ESP_OK;

err_freesocket:
    close(fd);
err_freeaddr:
    freeaddrinfo(addrinfo);
    return ret;
}


I setting like this(show attach file)

and my error log is this

I (59411) BF_WIFI*: esp_netif_create_default_wifi_sta
I (59421) BF_WIFI*: wifi_init_config_t
I (59421) BF_WIFI*: esp_wifi_init
I (59441) wifi:wifi driver task: 3ffe3580, prio:23, stack:6656, core=0
I (59441) wifi:wifi firmware version: eb52264
I (59451) wifi:wifi certification version: v7.0
I (59451) wifi:config NVS flash: enabled
I (59451) wifi:config nano formating: disabled
I (59451) wifi:Init data frame dynamic rx buffer num: 32
I (59461) wifi:Init management frame dynamic rx buffer num: 32
I (59461) wifi:Init management short buffer num: 32
I (59471) wifi:Init static tx buffer num: 16
I (59471) wifi:Init tx cache buffer num: 32
I (59471) wifi:Init static rx buffer size: 1600
I (59481) wifi:Init static rx buffer num: 10
I (59481) wifi:Init dynamic rx buffer num: 32
I (59491) wifi_init: rx ba win: 16
I (59491) wifi_init: tcpip mbox: 32
I (59491) wifi_init: udp mbox: 6
I (59501) wifi_init: tcp mbox: 6
I (59501) wifi_init: tcp tx win: 5744
I (59511) wifi_init: tcp rx win: 5744
I (59511) wifi_init: tcp mss: 1436
I (59511) wifi_init: WiFi/LWIP prefer SPIRAM
I (59521) BF_WIFI*: esp_wifi_set_mode result: 0
I (59551) BF_WIFI*: esp_wifi_set_config result: 0
I (59551) wifi:mode : sta (c4:dd:57:6a:a0:0c)
I (59551) wifi:enable tsf
I (59551) BF_WIFI*: esp_wifi_start result: 0
I (59551) BF_WIFI*: Start wifi connect
I (59571) wifi:new:<6,0>, old:<1,0>, ap:<255,255>, sta:<6,0>, prof:1
I (59581) wifi:state: init -> auth (b0)
I (59591) wifi:state: auth -> assoc (0)
I (59601) wifi:state: assoc -> run (10)
I (59921) wifi:connected with LuisIphone, aid = 1, channel 6, BW20, bssid = 0a:3d:e5:52:3c:89
I (59921) wifi:security: WPA2-PSK, phy: bgn, rssi: -44
I (59941) wifi:pm start, type: 1

I (60011) wifi:AP's beacon interval = 102400 us, DTIM period = 1
W (60011) wifi:<ba-add>idx:0 (ifx:0, 0a:3d:e5:52:3c:89), tid:0, ssn:2, winSize:64
I (60961) esp_netif_handlers: sta ip: 172.20.10.2, mask: 255.255.255.240, gw: 172.20.10.1
I (60961) BF_WIFI*: got ip:172.20.10.2
I (60961) BF_WIFI*: WI-FI connect bit result: 0x1
I (60971) BF_WIFI*: connected to ap SSID:LuisIphone password:11112222
I (61171) APP_MAIN: WIFI_Total_SendJson
I (61171) APP_MAIN: [WIFI_Total_Http_Send]WIFI_Total_client isn't NULL
I (61171) APP_MAIN: [WIFI_Total_Http_Send]esp_http_client_set_method error code: 0
I (61171) APP_MAIN: [WIFI_Total_Http_Send]esp_http_client_set_header Content-Type error code: 0
W (61181) HTTP_CLIENT: Begin connect to: https://log.bodyfriend.co.kr:443
W (61191) HTTP_CLIENT: Show again.Begin connect to: https://log.bodyfriend.co.kr:443, timeout: 2147483647
W (61201) TRANSPORT: client->transport->_connect is found
W (61211) esp-tls: host:log.bodyfriend.co.kr: strlen 20
W (61211) esp-tls: addrinfo->ai_family == AF_INET
W (61221) esp-tls: [esp_tcp_connect]fd 54 addrinfo->ai_addrlen 28
E (70481) esp-tls: [esp_tcp_connect]Failed to connnect to host (errno 113) (ret -1)
E (70481) esp-tls: [esp_tls_low_level_conn] Fail esp_tcp_connect
E (70481) esp-tls: Failed to open new connection
E (70491) TRANS_SSL: Failed to open a new connection
E (70491) HTTP_CLIENT: Connection failed, sock < 0
E (70501) APP_MAIN: Failed to open HTTP connection: ESP_ERR_HTTP_CONNECT
I (70501) BF_WIFI*: bf_wifi_connect.c
-http_event_handler():
-HTTP_EVENT_DISCONNECTED:
I (70511) BF_WIFI*: Last esp error code: 0x8004
I (70521) BF_WIFI*: Last mbedtls failure: 0x0
I (70521) APP_MAIN: [WIFI_Total_Http_Send]esp_http_client_cleanup error code: 0
I (70531) APP_MAIN: Fail to send testdata
I (70541) APP_MAIN: [BleWifiConnTask]Fail to send json
I (70561) APP_MAIN: [WIFI_Total_Stop]Disconnect esp_wifi
I (70561) wifi:state: run -> init (0)
I (70561) wifi:pm stop, total sleep time: 7699794 us / 10621401 us
Attachments
Screenshot_1.png
Screenshot_1.png (12.17 KiB) Viewed 6138 times

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: esp-tls: Failed to connnect to host (errno 113)

Postby ESP_YJM » Fri Dec 23, 2022 8:05 am

It seems your log not print any lwip log, you may need clean your build project and re-build. For DNS debug open, you may modify the clode https://github.com/espressif/esp-lwip/b ... pt.h#L3533. Change LWIP_DBG_OFF to LWIP_DBG_ON.

luisfynn
Posts: 10
Joined: Fri Feb 25, 2022 9:26 am

Re: esp-tls: Failed to connnect to host (errno 113)

Postby luisfynn » Mon Dec 26, 2022 12:12 am

ESP_YJM wrote:
Fri Dec 23, 2022 8:05 am
It seems your log not print any lwip log, you may need clean your build project and re-build. For DNS debug open, you may modify the clode https://github.com/espressif/esp-lwip/b ... pt.h#L3533. Change LWIP_DBG_OFF to LWIP_DBG_ON.
where can I turn on that option???

attached file is my menuconfig's LWIP
Attachments
Screenshot_2.png
Screenshot_2.png (37.74 KiB) Viewed 6011 times

luisfynn
Posts: 10
Joined: Fri Feb 25, 2022 9:26 am

Re: esp-tls: Failed to connnect to host (errno 113)

Postby luisfynn » Mon Dec 26, 2022 2:04 am

ESP_YJM wrote:
Fri Dec 23, 2022 8:05 am
It seems your log not print any lwip log, you may need clean your build project and re-build. For DNS debug open, you may modify the clode https://github.com/espressif/esp-lwip/b ... pt.h#L3533. Change LWIP_DBG_OFF to LWIP_DBG_ON.

I chaned async mode and insert debug code


this is debug log

Code: Select all

W (66967) RUN_MODE1: [BLE] Data : $ADBRnD_Officeyyyyyyyyyyyyyyyyyyyybody_rndyyyyyyyyyyyyyyyyyyyyyy?
W (66977) RUN_MODE1: [BLE] Run process, 0x6
E (66977) RUN_MODE1: Start WIFI connection
I (66987) APP_MAIN: BLE_TRANS_WIFI_CONN_SSID_FULL
I (66987) APP_MAIN: SSID:RnD_Office PASSWORD:body_rnd
I (66997) APP_MAIN: Delete wifi previous infomation
I (67077) APP_MAIN: bf_file write
W (67097) RUN_MODE1: [BLE] BleHead3 : 0 
W (67097) RUN_MODE1: [BLE] BleHead4 : 1 
I (67297) BF_SDCARD*: Read from sd: '>Z0K;RRUOQ
'
I (67297) BF_SDCARD*: Read from sd: 'N[PeK^ZP'
I (67297) APP_MAIN: [BleWifiConnTask]SSID:RnD_Office PASSWORD:body_rnd
I (67307) BF_WIFI*: esp_netif_init
W (67307) esp_netif_lwip: esp-netif has been successfully initialized
I (67317) BF_WIFI*: esp_event_loop_create_default
W (67317) event: created task for loop 0x3ffe3e1c
W (67327) event: created event loop 0x3ffe3e1c
I (67327) BF_WIFI*: esp_netif_create_default_wifi_sta
I (67337) BF_WIFI*: wifi_init_config_t
I (67337) BF_WIFI*: esp_wifi_init
I (67357) wifi:wifi driver task: 3ffe367c, prio:23, stack:6656, core=0
I (67367) wifi:wifi firmware version: eb52264
I (67367) wifi:wifi certification version: v7.0
I (67367) wifi:config NVS flash: enabled
I (67367) wifi:config nano formating: disabled
I (67367) wifi:Init data frame dynamic rx buffer num: 32
I (67377) wifi:Init management frame dynamic rx buffer num: 32
I (67377) wifi:Init management short buffer num: 32
I (67387) wifi:Init static tx buffer num: 16
I (67387) wifi:Init tx cache buffer num: 32
I (67397) wifi:Init static rx buffer size: 1600
I (67397) wifi:Init static rx buffer num: 10
I (67397) wifi:Init dynamic rx buffer num: 32
I (67407) wifi_init: rx ba win: 16
I (67407) wifi_init: tcpip mbox: 32
I (67417) wifi_init: udp mbox: 6
I (67417) wifi_init: tcp mbox: 6
I (67417) wifi_init: tcp tx win: 5744
I (67427) wifi_init: tcp rx win: 5744
I (67427) wifi_init: tcp mss: 1436
I (67437) wifi_init: WiFi/LWIP prefer SPIRAM
I (67437) BF_WIFI*: esp_wifi_set_mode result: 0
I (67507) BF_WIFI*: esp_wifi_set_config result: 0
I (67507) wifi:mode : sta (c4:dd:57:6a:a0:0c) + softAP (c4:dd:57:6a:a0:0d)
I (67507) wifi:enable tsf
I (67507) wifi:Total power save buffer number: 8
I (67507) BF_WIFI*: esp_wifi_start result: 0
netif: added interface st IP addr 0.0.0.0 netmask 0.0.0.0 gw 0.0.0.0
I (67517) BF_WIFI*: Start wifi connect
I (67537) wifi:ap channel adjust o:1,1 n:3,1
I (67537) wifi:new:<3,1>, old:<1,1>, ap:<3,1>, sta:<3,1>, prof:1
I (67537) wifi:state: init -> auth (b0)
I (67547) wifi:state: auth -> assoc (0)
I (67557) wifi:state: assoc -> run (10)
I (67567) wifi:connected with RnD_Office, aid = 2, channel 3, 40U, bssid = 58:86:94:9b:16:50
I (67567) wifi:security: WPA2-PSK, phy: bgn, rssi: -49
I (67577) wifi:pm start, type: 1

netif: setting default interface st
dhcp_start(netif=0x3ffe3320) st3
dhcp_start(): restarting DHCP configuration
dhcp_start(): starting DHCP configuration
dhcp_discover()
I (67587) wifi:dhcp_discover(): dhcp state is DISCOVER
AP's beacon interval = 102400 us, DTIM period = 3dhcp_select: could not allocate DHCP request

pbuf_alloc(length=308)
pbuf_alloc(length=308) == 0x3f8248ec
transaction id xid(b6f39655)
dhcp_discover: making request
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, LWIP_IANA_PORT_DHCP_SERVER)
pbuf_add_header: old 0x3f824950 new 0x3f824948 (8)
pbuf_add_header: old 0x3f824948 new 0x3f824934 (20)
ip4_output_if: st3
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |       336     | (v, hl, tos, len)
+-------------------------------+
|       18      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |   17  |    0xba8b     | (ttl, proto, chksum)
+-------------------------------+
|    0  |    0  |    0  |    0  | (src)
+-------------------------------+
|  255  |  255  |  255  |  255  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3f824934 new 0x3f824926 (14)
ethernet_output: sending packet 0x3f8248ec
dhcp_discover: deleting()ing
pbuf_free(0x3f8248ec)
pbuf_free(0x3f8248ec)
pbuf_free: 0x3f8248ec has ref 1, ending here.
pbuf_free: deallocating 0x3f8248ec
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 500 msecs
pbuf_alloc(length=590)
pbuf_alloc(length=590) == 0x3f815f24
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:58:86:94:9b:16:50, type:800
pbuf_remove_header: old 0x3f82497e new 0x3f82498c (14)
ip_input: iphdr->dest 0xffffffff netif->ip_addr 0x0 (0x0, 0x0, 0xffffffff)
ip_input: iphdr->dest 0xffffffff netif->ip_addr 0x100007f (0xff, 0x7f, 0xffffff00)
ip4_input: packet accepted on interface lo
ip4_input: 
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |       576     | (v, hl, tos, len)
+-------------------------------+
|        0      |000|       0   | (id, flags, offset)
+-------------------------------+
|   64  |   17  |    0xb804     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    1  | (src)
+-------------------------------+
|  255  |  255  |  255  |  255  | (dest)
+-------------------------------+
ip4_input: p->len 576 p->tot_len 576
pbuf_remove_header: old 0x3f82498c new 0x3f8249a0 (20)
pbuf_remove_header: old 0x3f8249a0 new 0x3f8249a8 (8)
dhcp_recv(pbuf = 0x3f815f24) from DHCP server 192.168.0.1 port 67
pbuf->len = 548
pbuf->tot_len = 548
searching DHCP_OPTION_MESSAGE_TYPE
DHCP_OFFER received in DHCP_STATE_SELECTING state
dhcp_handle_offer(netif=0x3ffe3320) st3
dhcp_handle_offer(): server 0x0100a8c0
dhcp_handle_offer(): offer for 0x0500a8c0
dhcp_select(netif=0x3ffe3320) st3
dhcp_select(): dhcp state is REQUESTING
pbuf_alloc(length=308)
pbuf_alloc(length=308) == 0x3f824f90
transaction id xid(b6f39655)
pbuf_add_header: old 0x3f824ff4 new 0x3f824fec (8)
pbuf_add_header: old 0x3f824fec new 0x3f824fd8 (20)
ip4_output_if: st3
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |       336     | (v, hl, tos, len)
+-------------------------------+
|       19      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |   17  |    0xba8a     | (ttl, proto, chksum)
+-------------------------------+
|    0  |    0  |    0  |    0  | (src)
+-------------------------------+
|  255  |  255  |  255  |  255  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3f824fd8 new 0x3f824fca (14)
ethernet_output: sending packet 0x3f824f90
pbuf_free(0x3f824f90)
pbuf_free: 0x3f824f90 has ref 1, ending here.
pbuf_free(0x3f824f90)
pbuf_free: deallocating 0x3f824f90
dhcp_select: REQUESTING
dhcp_select(): set request timeout 2000 msecs
pbuf_free(0x3f815f24)
pbuf_free: deallocating 0x3f815f24
pbuf_alloc(length=590)
etharp_timer
pbuf_alloc(length=590) == 0x3f815f24
dhcp_coarse_tmr()
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:58:86:94:9b:16:50, type:800
pbuf_remove_header: old 0x3f825022 new 0x3f825030 (14)
ip_input: iphdr->dest 0xffffffff netif->ip_addr 0x0 (0x0, 0x0, 0xffffffff)
ip_input: iphdr->dest 0xffffffff netif->ip_addr 0x100007f (0xff, 0x7f, 0xffffff00)
ip4_input: packet accepted on interface lo
ip4_input: 
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |       576     | (v, hl, tos, len)
+-------------------------------+
|        0      |000|       0   | (id, flags, offset)
+-------------------------------+
|   64  |   17  |    0xb804     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    1  | (src)
+-------------------------------+
|  255  |  255  |  255  |  255  | (dest)
+-------------------------------+
ip4_input: p->len 576 p->tot_len 576
pbuf_remove_header: old 0x3f825030 new 0x3f825044 (20)
pbuf_remove_header: old 0x3f825044 new 0x3f82504c (8)
dhcp_recv(pbuf = 0x3f815f24) from DHCP server 192.168.0.1 port 67
pbuf->len = 548
pbuf->tot_len = 548
searching DHCP_OPTION_MESSAGE_TYPE
DHCP_ACK received
dhcp_check(netif=0x3ffe3320) st
dhcp_check(): dhcp state is CHECKING
etharp_find_entry: found empty entry 0
etharp_find_entry: selecting empty entry 0
etharp_request: sending ARP request.
pbuf_alloc(length=28)
pbuf_alloc(length=28) == 0x3f8248ec
etharp_raw: sending raw ARP packet.
pbuf_add_header: old 0x3f824914 new 0x3f824906 (14)
ethernet_output: sending packet 0x3f8248ec
pbuf_free(0x3f8248ec)
pbuf_free(0x3f8248ec)
pbuf_free: 0x3f8248ec has ref 1, ending here.
dhcp_check(): set request timeout 500 msecs
pbuf_free: deallocating 0x3f8248ec
pbuf_free(0x3f815f24)
pbuf_free: deallocating 0x3f815f24
dhcp_fine_tmr(): request timeout
dhcp_timeout()
dhcp_timeout(): CHECKING, ARP request timed out
dhcp_check(netif=0x3ffe3320) st
dhcp_check(): dhcp state is CHECKING
etharp_find_entry: found matching entry 0
etharp_request: sending ARP request.
pbuf_alloc(length=28)
pbuf_alloc(length=28) == 0x3f8248ec
etharp_raw: sending raw ARP packet.
pbuf_add_header: old 0x3f824914 new 0x3f824906 (14)
ethernet_output: sending packet 0x3f8248ec
pbuf_free(0x3f8248ec)
pbuf_free(0x3f8248ec)
pbuf_free: 0x3f8248ec has ref 1, ending here.
pbuf_free: deallocating 0x3f8248ec
dhcp_check(): set request timeout 500 msecs
etharp_timer
etharp_request: sending ARP request.
pbuf_alloc(length=28)
pbuf_alloc(length=28) == 0x3f8248ec
etharp_raw: sending raw ARP packet.
pbuf_add_header: old 0x3f824914 new 0x3f824906 (14)
ethernet_output: sending packet 0x3f8248ec
pbuf_free(0x3f8248ec)
pbuf_free(0x3f8248ec)
pbuf_free: 0x3f8248ec has ref 1, ending here.
pbuf_free: deallocating 0x3f8248ec
dhcp_coarse_tmr()
dhcp_fine_tmr(): request timeout
dhcp_timeout()
dhcp_timeout(): CHECKING, ARP request timed out
dhcp_bind(netif=0x3ffe3320) st3
dhcp_bind(): t0 renewal timer 7200 secs
dhcp_bind(): set request timeout 7200000 msecs
dhcp_bind(): t1 renewal timer 3600 secs
dhcp_bind(): set request timeout 3600000 msecs
dhcp_bind(): t2 rebind timer 6300 secs
dhcp_bind(): set request timeout 6300000 msecs
dhcp_bind(): IP: 0x0500a8c0 SN: 0x00ffffff GW: 0x0100a8c0
dhcp_bind(): dhcp state is BOUND
netif: netmask of interface st set to 255.255.255.0
netif: GW address of interface st set to 192.168.0.1
netif_set_ipaddr: netif address being changed
etharp_request: sending ARP request.
pbuf_alloc(length=28)
pbuf_alloc(length=28) == 0x3f8248ec
etharp_raw: sending raw ARP packet.
pbuf_add_header: old 0x3f824914 new 0x3f824906 (14)
ethernet_output: sending packet 0x3f8248ec
pbuf_free(0x3f8248ec)
pbuf_free(0x3f8248ec)
pbuf_free: 0x3f8248ec has ref 1, ending here.
pbuf_free: deallocating 0x3f8248ec
I (69017) esp_netif_handlers: sta ip: 192.168.0.5, mask: 255.255.255.0, gw: 192.168.0.1
I (69017) BF_WIFI*: got ip:192.168.0.5
I (69027) BF_WIFI*: WI-FI connect bit result: 0x1
I (69027) BF_WIFI*: connected to ap SSID:RnD_Office password:body_rnd
I (69037) APP_MAIN: WIFI_Total_SendJson
W (69047) HTTP_CLIENT: max_redirection_count 50
I (69047) APP_MAIN: [WIFI_Total_Http_Send]WIFI_Total_client isn't NULL
I (69057) APP_MAIN: [WIFI_Total_Http_Send]esp_http_client_set_method error code: 0
I (69067) APP_MAIN: [WIFI_Total_Http_Send]esp_http_client_set_header Content-Type error code: 0
W (69077) HTTP_CLIENT: Begin connect to: https://log.bodyfriend.co.kr:443
W (69077) esp-tls: host:log.bodyfriend.co.kr: strlen 20
lwip_socket(PF_INET, SOCK_STREAM, 0) = 54
W (69087) esp-tls: addrinfo->ai_family == AF_INET
W (69097) esp-tls: [esp_tcp_connect]fd 54 addrinfo->ai_addrlen 28
lwip_connect(54, addr=121.138.34.172 port=443)
tcp_connect to port 443
pbuf_alloc(length=4)
pbuf_alloc(length=4) == 0x3f824b40
pbuf_add_header: old 0x3f824ba4 new 0x3f824b90 (20)
pbuf_add_header: old 0x3f824b90 new 0x3f824b7c (20)
ip4_output_if: st3
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        44     | (v, hl, tos, len)
+-------------------------------+
|       20      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0x5ed4     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    5  | (src)
+-------------------------------+
|  121  |  138  |   34  |  172  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
etharp_find_entry: found empty entry 1
etharp_find_entry: selecting empty entry 1
etharp_request: sending ARP request.
pbuf_alloc(length=28)
pbuf_alloc(length=28) == 0x3f824bc0
etharp_raw: sending raw ARP packet.
pbuf_add_header: old 0x3f824be8 new 0x3f824bda (14)
ethernet_output: sending packet 0x3f824bc0
pbuf_free(0x3f824bc0)
pbuf_free(0x3f824bc0)
pbuf_free: 0x3f824bc0 has ref 1, ending here.
pbuf_free: deallocating 0x3f824bc0
etharp_query: queued packet 0x3f824b40 on ARP entry 1
lwip_connect(54) failed, err=-5
W (69217) esp-tls: connecting...
lwip_select(55, 0x3ffebcd4, 0x3ffebcdc, 0x0, tvsec=2147483 tvusec=647000)
pbuf_alloc(length=42)
pbuf_alloc(length=42) == 0x3f824bec
ethernet_input: dest:c4:dd:57:6a:a0:0c, src:58:86:94:9b:16:50, type:806
W (69237) wifi:pbuf_remove_header: old 0x3f824cac new 0x3f824cba (14)
<ba-add>idx:0 (ifx:0, 58:86:94:9b:16:50), tid:0, ssn:2, winSize:64etharp_update_arp_entry: 192.168.0.1 - 58:86:94:9b:16:50

etharp_find_entry: found matching entry 1
etharp_update_arp_entry: updating stable entry 1
pbuf_add_header: old 0x3f824b7c new 0x3f824b6e (14)
ethernet_output: sending packet 0x3f824b40
pbuf_free(0x3f824b40)
pbuf_free(0x3f824b40)
pbuf_free: 0x3f824b40 has ref 2, ending here.
pbuf_free: 0x3f824b40 has ref 1, ending here.
etharp_input: incoming ARP reply
dhcp_arp_reply()
pbuf_free(0x3f824bec)
pbuf_free: deallocating 0x3f824bec
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
etharp_timer
etharp_request: sending ARP request.
pbuf_alloc(length=28)
pbuf_alloc(length=28) == 0x3f8249c0
etharp_raw: sending raw ARP packet.
pbuf_add_header: old 0x3f8249e8 new 0x3f8249da (14)
ethernet_output: sending packet 0x3f8249c0
pbuf_free(0x3f8249c0)
pbuf_free: 0x3f8249c0 has ref 1, ending here.
pbuf_free(0x3f8249c0)
pbuf_free: deallocating 0x3f8249c0
dhcp_coarse_tmr()
tcp_slowtmr: processing active pcb
pbuf_add_header: old 0x3f824b90 new 0x3f824b7c (20)
ip4_output_if: st3
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        44     | (v, hl, tos, len)
+-------------------------------+
|       21      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0x5ed3     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    5  | (src)
+-------------------------------+
|  121  |  138  |   34  |  172  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3f824b7c new 0x3f824b6e (14)
ethernet_output: sending packet 0x3f824b40
pbuf_free(0x3f824b40)
pbuf_free: 0x3f824b40 has ref 1, ending here.
etharp_timer
etharp_request: sending ARP request.
pbuf_alloc(length=28)
pbuf_alloc(length=28) == 0x3f8249c0
etharp_raw: sending raw ARP packet.
pbuf_add_header: old 0x3f8249e8 new 0x3f8249da (14)
ethernet_output: sending packet 0x3f8249c0
pbuf_free(0x3f8249c0)
pbuf_free(0x3f8249c0)
pbuf_free: 0x3f8249c0 has ref 1, ending here.
pbuf_free: deallocating 0x3f8249c0
dhcp_coarse_tmr()
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
etharp_timer
etharp_request: sending ARP request.
pbuf_alloc(length=28)
pbuf_alloc(length=28) == 0x3f8249c0
etharp_raw: sending raw ARP packet.
pbuf_add_header: old 0x3f8249e8 new 0x3f8249da (14)
ethernet_output: sending packet 0x3f8249c0
pbuf_free(0x3f8249c0)
pbuf_free: 0x3f8249c0 has ref 1, ending here.
pbuf_free(0x3f8249c0)
pbuf_free: deallocating 0x3f8249c0
dhcp_coarse_tmr()
tcp_slowtmr: processing active pcb
pbuf_add_header: old 0x3f824b90 new 0x3f824b7c (20)
ip4_output_if: st3
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        44     | (v, hl, tos, len)
+-------------------------------+
|       22      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0x5ed2     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    5  | (src)
+-------------------------------+
|  121  |  138  |   34  |  172  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3f824b7c new 0x3f824b6e (14)
ethernet_output: sending packet 0x3f824b40
tcp_slowtmr: polling application
pbuf_free(0x3f824b40)
pbuf_free: 0x3f824b40 has ref 1, ending here.
tcp_slowtmr: processing active pcb
etharp_timer
etharp_timer: expired pending entry 0.
dhcp_coarse_tmr()
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
pbuf_add_header: old 0x3f824b90 new 0x3f824b7c (20)
ip4_output_if: st3
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        44     | (v, hl, tos, len)
+-------------------------------+
|       23      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0x5ed1     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    5  | (src)
+-------------------------------+
|  121  |  138  |   34  |  172  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3f824b7c new 0x3f824b6e (14)
ethernet_output: sending packet 0x3f824b40
pbuf_free(0x3f824b40)
pbuf_free: 0x3f824b40 has ref 1, ending here.
pbuf_alloc(length=46)
pbuf_alloc(length=46) == 0x3f8249c0
ethernet_input: dest:c4:dd:57:6a:a0:0c, src:58:86:94:9b:16:50, type:800
pbuf_remove_header: old 0x3f824c80 new 0x3f824c8e (14)
ip4_input: 
IP header:
+-------------------------------+
| 4 | 6 |  0x00 |        32     | (v, hl, tos, len)
+-------------------------------+
|    53224      |010|       0   | (id, flags, offset)
+-------------------------------+
|    1  |    2  |    0x7444     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    1  | (src)
+-------------------------------+
|  224  |    0  |    0  |    1  | (dest)
+-------------------------------+
ip4_input: p->len 32 p->tot_len 32
pbuf_remove_header: old 0x3f824c8e new 0x3f824ca6 (24)
pbuf_free(0x3f8249c0)
pbuf_free: deallocating 0x3f8249c0
etharp_timer
dhcp_coarse_tmr()
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
etharp_timer
dhcp_coarse_tmr()
tcp_slowtmr: processing active pcb
pbuf_add_header: old 0x3f824b90 new 0x3f824b7c (20)
ip4_output_if: st3
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        44     | (v, hl, tos, len)
+-------------------------------+
|       24      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0x5ed0     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    5  | (src)
+-------------------------------+
|  121  |  138  |   34  |  172  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3f824b7c new 0x3f824b6e (14)
ethernet_output: sending packet 0x3f824b40
pbuf_free(0x3f824b40)
pbuf_free: 0x3f824b40 has ref 1, ending here.
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
etharp_timer
dhcp_coarse_tmr()
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
pbuf_add_header: old 0x3f824b90 new 0x3f824b7c (20)
ip4_output_if: st3
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        44     | (v, hl, tos, len)
+-------------------------------+
|       25      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0x5ecf     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    5  | (src)
+-------------------------------+
|  121  |  138  |   34  |  172  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3f824b7c new 0x3f824b6e (14)
ethernet_output: sending packet 0x3f824b40
pbuf_free(0x3f824b40)
pbuf_free: 0x3f824b40 has ref 1, ending here.
etharp_timer
dhcp_coarse_tmr()
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
etharp_timer
dhcp_coarse_tmr()
tcp_slowtmr: processing active pcb
pbuf_add_header: old 0x3f824b90 new 0x3f824b7c (20)
ip4_output_if: st3
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        44     | (v, hl, tos, len)
+-------------------------------+
|       26      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0x5ece     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    5  | (src)
+-------------------------------+
|  121  |  138  |   34  |  172  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3f824b7c new 0x3f824b6e (14)
ethernet_output: sending packet 0x3f824b40
pbuf_free(0x3f824b40)
pbuf_free: 0x3f824b40 has ref 1, ending here.
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: max SYN retries reached
tcp_pcb_purge
tcp_pcb_purge: data left on ->unacked
pbuf_free(0x3f824b40)
pbuf_free: deallocating 0x3f824b40
lwip_selscan: fd=54 ready for reading
lwip_selscan: fd=54 ready for writing
lwip_select: nready=2
lwip_getsockopt(54, SOL_SOCKET, SO_ERROR) = 113
W (78807) esp-tls: handshake in progress...
lwip_send(54, data=0x3f829b38, size=220, flags=0x0)
lwip_send(54) err=-11 written=0
E (78807) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x4e, 0xffffffb2
I (78817) esp-tls-mbedtls: Certificate verified.
E (78817) HTTP_CLIENT: Connection failed
E (78827) APP_MAIN: Error perform http request ESP_OK
I (78827) BF_WIFI*: bf_wifi_connect.c
		-http_event_handler():
		-HTTP_EVENT_DISCONNECTED:
lwip_shutdown(54, how=2)
lwip_close(54)
I (78847) APP_MAIN: [WIFI_Total_Http_Send]esp_http_client_cleanup error code: 0
I (78847) APP_MAIN: Fail to send testdata
I (78857) APP_MAIN: [BleWifiConnTask]Fail to send json
I (78877) APP_MAIN: [WIFI_Total_Stop]Disconnect esp_wifi
I (78877) wifi:state: run -> init (0)
I (78877) wifi:pm stop, total sleep time: 9029637 us / 11301164 us

W (78877) wifi:<ba-del>idx
I (78887) wifi:new:<3,0>, old:<3,1>, ap:<3,1>, sta:<3,1>, prof:1
I (78887) APP_MAIN: [WIFI_Total_Stop]Stop esp_wifi
dhcp_release_and_stop()
pbuf_alloc(length=308)
pbuf_alloc(length=308) == 0x3f824774
I (78897) wifi:transaction id xid(ff85c867)
flush txq
pbuf_add_header: old 0x3f8247d8 new 0x3f8247d0 (8)
I (78907) wifi:stop sw txqpbuf_add_header: old 0x3f8247d0 new 0x3f8247bc (20)

ip4_output_if: st3
I (78917) wifi:IP header:
lmac stop hw txq+-------------------------------+

| 4 | 5 |  0x00 |       336     | (v, hl, tos, len)
I (78927) APP_MAIN: [WIFI_Total_Stop]Deinit esp wifi
+-------------------------------+
I (78937) wifi:|       27      |000|       0   | (id, flags, offset)
Deinit lldesc rx mblock:10
+-------------------------------+
|  255  |   17  |    0x392b     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    0  |    5  | (src)
+-------------------------------+
|  192  |  168  |    0  |    1  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
pbuf_add_header: old 0x3f8247bc new 0x3f8247ae (14)
ethernet_output: sending packet 0x3f824774
W (78987) wifi:hmac tx: ifx0 stop, discard
pbuf_free(0x3f824774)
pbuf_free: deallocating 0x3f824774
dhcp_release: RELEASED, DHCP_STATE_OFF
netif_set_ipaddr: netif address being changed
netif: netmask of interface st set to 0.0.0.0
netif: GW address of interface st set to 0.0.0.0
dhcp_release_and_stop(): dhcp state is OFF
netif: IPv6 address 0 of interface st set to ::/0x00
netif: IPv6 address 0 of interface st set to ::/0x00
netif: IPv6 address 1 of interface st set to ::/0x00
netif: IPv6 address 1 of interface st set to ::/0x00
netif: IPv6 address 2 of interface st set to ::/0x00
netif: IPv6 address 2 of interface st set to ::/0x00
etharp_timer
I (79037) APP_MAIN: [WIFI_Total_Stop]Destroy g_bf_myAP
dhcp_coarse_tmr()
netif: setting default interface ''
netif_remove: removed netif
W (79057) APP_MAIN: Delete BleWifiConnTask
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
etharp_timer
dhcp_coarse_tmr()
ets Jul 29 2019 12:21:46

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: esp-tls: Failed to connnect to host (errno 113)

Postby ESP_YJM » Mon Dec 26, 2022 2:18 am

From your log, it seems the max SYN retries reached and peer no response. You need check whether the packet sent out from WIFI, it need capture air packet or route packet.

luisfynn
Posts: 10
Joined: Fri Feb 25, 2022 9:26 am

Re: esp-tls: Failed to connnect to host (errno 113)

Postby luisfynn » Mon Dec 26, 2022 2:59 am

ESP_YJM wrote:
Mon Dec 26, 2022 2:18 am
From your log, it seems the max SYN retries reached and peer no response. You need check whether the packet sent out from WIFI, it need capture air packet or route packet.
how I capture air packet?? please let me know.

Who is online

Users browsing this forum: Google [Bot] and 61 guests