1、芯片 ESP32-D0WDQ6-V3
2、IDF版本esp-idf-v4.4.2
3、例程 esp-http-client 中的https部分,在configuration editor 中已经选择了Skip server certificate
例程中运行就能正常连接,移植后就一直报错
(1)正常连接
static void https_with_url(void)
{
esp_http_client_config_t config = {
// .url = "https://www.howsmyssl.com",
.url = "https://api.ubibot.cn/heartbeat?api_key ... abf2bd3e0a",
// .event_handler = _http_event_handler,
// .crt_bundle_attach = esp_crt_bundle_attach,
.skip_cert_common_name_check=true,
.method=HTTP_METHOD_GET,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_open(client, 0);
if (err == ESP_OK)
{
ESP_LOGI(TAG, "%d,Connection to server successfully\r\n", __LINE__);
esp_err_t err1 =esp_http_client_fetch_headers(client);
if (err1>= 0)
{
ESP_LOGE(TAG, "content_length=%d", err1);
memset(NET_RX_BUFFER, 0, sizeof(NET_RX_BUFFER));
int data_read = esp_http_client_read_response(client, NET_RX_BUFFER, sizeof(NET_RX_BUFFER));
if (data_read >= 0)
{
int lRetVal=esp_http_client_get_status_code(client);
ESP_LOGI(TAG, "HTTP Status = %d, data_read = %d", lRetVal, data_read);
ESP_LOGI(TAG, "GET Request READ:\n%s", NET_RX_BUFFER);
}
}
}
else
{
ESP_LOGE(TAG, "esp_http_client_open FAIL:err=%d\r\n",err);
}
esp_http_client_cleanup(client);
}
返回
E (8477) HTTP_CLIENT: content_length=0
I (8477) HTTP_CLIENT: HTTP Status = 410, data_read = 98
I (8477) HTTP_CLIENT: GET Request READ:
{"result":"error","server_time":"2024-08-07T00:45:41Z","errorCode":"invalid_channel_id","desp":""}
I (8497) HTTP_CLIENT: Finish http example
(2)移植后连接报错
I (7560) HttpMqttClient: 767.WiFi http start.
I (7855) mbedtls: ssl_tls.c:5904 => handshake
I (7860) mbedtls: ssl_cli.c:4483 client state: 0
I (7860) mbedtls: ssl_msg.c:2102 => flush output
I (7865) mbedtls: ssl_msg.c:2114 <= flush output
I (7870) mbedtls: ssl_cli.c:4483 client state: 1
I (7875) mbedtls: ssl_msg.c:2102 => flush output
I (7880) mbedtls: ssl_msg.c:2114 <= flush output
I (7885) mbedtls: ssl_cli.c:999 => write client hello
I (7890) mbedtls: ssl_msg.c:2542 => write handshake message
I (7895) mbedtls: ssl_msg.c:2701 => write record
I (7905) mbedtls: ssl_msg.c:2102 => flush output
I (7910) mbedtls: ssl_msg.c:2122 message length: 222, out_left: 222
I (7920) mbedtls: ssl_msg.c:2127 ssl->f_send() returned 222 (-0xffffff22)
I (7925) mbedtls: ssl_msg.c:2155 <= flush output
I (7930) mbedtls: ssl_msg.c:2870 <= write record
I (7935) mbedtls: ssl_msg.c:2678 <= write handshake message
I (7940) mbedtls: ssl_cli.c:1467 <= write client hello
I (7945) mbedtls: ssl_cli.c:4483 client state: 2
I (7950) mbedtls: ssl_msg.c:2102 => flush output
I (7955) mbedtls: ssl_msg.c:2114 <= flush output
I (7960) mbedtls: ssl_cli.c:2082 => parse server hello
I (7970) mbedtls: ssl_msg.c:3941 => read record
I (7975) mbedtls: ssl_msg.c:1886 => fetch input
I (7980) mbedtls: ssl_msg.c:2043 in_left: 0, nb_want: 5
I (7985) mbedtls: ssl_msg.c:2068 in_left: 0, nb_want: 5
I (7990) mbedtls: ssl_msg.c:2069 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
I (8000) mbedtls: ssl_msg.c:2089 <= fetch input
I (8005) mbedtls: ssl_msg.c:1886 => fetch input
I (8010) mbedtls: ssl_msg.c:2043 in_left: 5, nb_want: 66
I (8015) mbedtls: ssl_msg.c:2068 in_left: 5, nb_want: 66
I (8025) mbedtls: ssl_msg.c:2069 ssl->f_recv(_timeout)() returned 61 (-0xffffffc3)
I (8030) mbedtls: ssl_msg.c:2089 <= fetch input
I (8035) mbedtls: ssl_msg.c:4015 <= read record
I (8040) mbedtls: ssl_cli.c:2385 server hello, total extension length: 17
I (8050) mbedtls: ssl_cli.c:2627 <= parse server hello
I (8055) mbedtls: ssl_cli.c:4483 client state: 3
I (8060) mbedtls: ssl_msg.c:2102 => flush output
I (8065) mbedtls: ssl_msg.c:2114 <= flush output
I (8070) mbedtls: ssl_tls.c:2878 => parse certificate
I (8080) mbedtls: ssl_msg.c:3941 => read record
I (8085) mbedtls: ssl_msg.c:1886 => fetch input
I (8090) mbedtls: ssl_msg.c:2043 in_left: 0, nb_want: 5
I (8095) mbedtls: ssl_msg.c:2068 in_left: 0, nb_want: 5
I (8100) mbedtls: ssl_msg.c:2069 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
I (8110) mbedtls: ssl_msg.c:2089 <= fetch input
I (8115) mbedtls: ssl_msg.c:1886 => fetch input
I (8120) mbedtls: ssl_msg.c:2043 in_left: 5, nb_want: 5657
I (8130) mbedtls: ssl_msg.c:2068 in_left: 5, nb_want: 5657
I (8135) mbedtls: ssl_msg.c:2069 ssl->f_recv(_timeout)() returned 2809 (-0xfffff507)
I (8580) mbedtls: ssl_msg.c:2068 in_left: 2814, nb_want: 5657
I (8580) mbedtls: ssl_msg.c:2069 ssl->f_recv(_timeout)() returned 2843 (-0xfffff4e5)
I (8585) mbedtls: ssl_msg.c:2089 <= fetch input
I (8595) mbedtls: ssl_msg.c:4015 <= read record
I (8600) mbedtls: ssl_msg.c:4990 => send alert message
I (8605) mbedtls: ssl_msg.c:2701 => write record
I (8610) mbedtls: ssl_msg.c:2102 => flush output
I (8615) mbedtls: ssl_msg.c:2122 message length: 7, out_left: 7
I (14490) mbedtls: ssl_msg.c:2127 ssl->f_send() returned -26752 (-0x6880)
W (14490) mbedtls: ssl_msg.c:2866 mbedtls_ssl_flush_output() returned -26752 (-0x6880)
W (14495) mbedtls: ssl_msg.c:5000 mbedtls_ssl_write_record() returned -26752 (-0x6880)
W (14505) mbedtls: ssl_tls.c:2528 mbedtls_x509_crt_parse_der() returned -10368 (-0x2880)
I (14510) mbedtls: ssl_tls.c:5915 <= handshake
E (14515) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x2880
E (14525) esp-tls: Failed to open new connection
E (14530) TRANSPORT_BASE: Failed to open a new connection
E (14540) HTTP_CLIENT: Connection failed, sock < 0
E (14540) HttpMqttClient: esp_http_client_open FAIL:err=28674
I (14605) mbedtls: ssl_tls.c:5904 => handshake
I (14610) mbedtls: ssl_cli.c:4483 client state: 0
I (14610) mbedtls: ssl_msg.c:2102 => flush output
I (14615) mbedtls: ssl_msg.c:2114 <= flush output
I (14620) mbedtls: ssl_cli.c:4483 client state: 1
I (14625) mbedtls: ssl_msg.c:2102 => flush output
I (14630) mbedtls: ssl_msg.c:2114 <= flush output
I (14635) mbedtls: ssl_cli.c:999 => write client hello
I (14640) mbedtls: ssl_msg.c:2542 => write handshake message
I (14650) mbedtls: ssl_msg.c:2701 => write record
I (14655) mbedtls: ssl_msg.c:2102 => flush output
I (14660) mbedtls: ssl_msg.c:2122 message length: 222, out_left: 222
I (14670) mbedtls: ssl_msg.c:2127 ssl->f_send() returned 222 (-0xffffff22)
I (14675) mbedtls: ssl_msg.c:2155 <= flush output
I (14680) mbedtls: ssl_msg.c:2870 <= write record
I (14685) mbedtls: ssl_msg.c:2678 <= write handshake message
I (14690) mbedtls: ssl_cli.c:1467 <= write client hello
I (14695) mbedtls: ssl_cli.c:4483 client state: 2
I (14705) mbedtls: ssl_msg.c:2102 => flush output
I (14710) mbedtls: ssl_msg.c:2114 <= flush output
I (14715) mbedtls: ssl_cli.c:2082 => parse server hello
I (14720) mbedtls: ssl_msg.c:3941 => read record
I (14725) mbedtls: ssl_msg.c:1886 => fetch input
I (14730) mbedtls: ssl_msg.c:2043 in_left: 0, nb_want: 5
I (14740) mbedtls: ssl_msg.c:2068 in_left: 0, nb_want: 5
I (14745) mbedtls: ssl_msg.c:2069 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
I (14750) mbedtls: ssl_msg.c:2089 <= fetch input
I (14755) mbedtls: ssl_msg.c:1886 => fetch input
I (14765) mbedtls: ssl_msg.c:2043 in_left: 5, nb_want: 66
I (14770) mbedtls: ssl_msg.c:2068 in_left: 5, nb_want: 66
I (14775) mbedtls: ssl_msg.c:2069 ssl->f_recv(_timeout)() returned 61 (-0xffffffc3)
I (14785) mbedtls: ssl_msg.c:2089 <= fetch input
I (14790) mbedtls: ssl_msg.c:4015 <= read record
I (14795) mbedtls: ssl_cli.c:2385 server hello, total extension length: 17
I (14800) mbedtls: ssl_cli.c:2627 <= parse server hello
I (14810) mbedtls: ssl_cli.c:4483 client state: 3
I (14815) mbedtls: ssl_msg.c:2102 => flush output
I (14820) mbedtls: ssl_msg.c:2114 <= flush output
I (14825) mbedtls: ssl_tls.c:2878 => parse certificate
I (14830) mbedtls: ssl_msg.c:3941 => read record
I (14835) mbedtls: ssl_msg.c:1886 => fetch input
I (14840) mbedtls: ssl_msg.c:2043 in_left: 0, nb_want: 5
I (14850) mbedtls: ssl_msg.c:2068 in_left: 0, nb_want: 5
I (14855) mbedtls: ssl_msg.c:2069 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
I (14865) mbedtls: ssl_msg.c:2089 <= fetch input
I (14870) mbedtls: ssl_msg.c:1886 => fetch input
I (14875) mbedtls: ssl_msg.c:2043 in_left: 5, nb_want: 5657
I (14880) mbedtls: ssl_msg.c:2068 in_left: 5, nb_want: 5657
I (14885) mbedtls: ssl_msg.c:2069 ssl->f_recv(_timeout)() returned 4249 (-0xffffef67)
I (14925) mbedtls: ssl_msg.c:2068 in_left: 4254, nb_want: 5657
I (14925) mbedtls: ssl_msg.c:2069 ssl->f_recv(_timeout)() returned 1403 (-0xfffffa85)
I (14930) mbedtls: ssl_msg.c:2089 <= fetch input
I (14935) mbedtls: ssl_msg.c:4015 <= read record
I (14940) mbedtls: ssl_msg.c:4990 => send alert message
I (14945) mbedtls: ssl_msg.c:2701 => write record
I (14950) mbedtls: ssl_msg.c:2102 => flush output
I (14955) mbedtls: ssl_msg.c:2122 message length: 7, out_left: 7
I (20490) mbedtls: ssl_msg.c:2127 ssl->f_send() returned -26752 (-0x6880)
W (20490) mbedtls: ssl_msg.c:2866 mbedtls_ssl_flush_output() returned -26752 (-0x6880)
W (20495) mbedtls: ssl_msg.c:5000 mbedtls_ssl_write_record() returned -26752 (-0x6880)
W (20505) mbedtls: ssl_tls.c:2528 mbedtls_x509_crt_parse_der() returned -10368 (-0x2880)
I (20510) mbedtls: ssl_tls.c:5915 <= handshake
E (20515) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x2880
E (20525) esp-tls: Failed to open new connection
E (20530) TRANSPORT_BASE: Failed to open a new connection
E (20540) HTTP_CLIENT: Connection failed, sock < 0
E (20540) HttpMqttClient: esp_http_client_open FAIL:ESP_ERR_HTTP_CONNECT
esp32 使用https 例程运行正常,移植后就运行异常
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 188 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.