Closed
Description
Hardware:
Board: ESP32 DoIt devkit
Core Installation version: idf-release/v4.0
IDE name: Platform.io / IDF component?
Flash Frequency: 40Mhz
Computer OS: Manjaro (Arch)
Description:
Using WiFiClientSecure to connect to anything results in a DNS failure, and subsequently an error in freertos/event_groups.c.
I tried with and without the calls to dns_setserver
.
The line that is causing the failed assert
in event_groups.c is:
/* Check the user is not attempting to set the bits used by the kernel
itself. */
configASSERT( xEventGroup );
The CA cert being used is the one from the example file from this repo.
I tried manually patching in the changed from this PR but it made no difference.
Sketch: (leave the backquotes for code formatting)
void WiFiManager::Init(){
tcpip_adapter_init();
wifiEvtGrp = xEventGroupCreate();
ESP_ERROR_CHECK( esp_event_loop_init(ipEventHandler, NULL) );
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start());
}
esp_err_t WiFiManager::ipEventHandler(void *ctx, system_event_t *event){
if(event->event_id == SYSTEM_EVENT_STA_GOT_IP){
WIFI_INFO("STA_GOT_IP");
ip_addr_t dnsserver;
IP_ADDR4( &dnsserver, 8,8,8,8);
dns_setserver(0, &dnsserver);
IP_ADDR4( &dnsserver, 8,8,4,4);
dns_setserver(1, &dnsserver);
WiFiClientSecure client;
client.setCACert(caCert);
Serial.println("\nStarting connection to server...");
if (!client.connect("www.howsmyssl.com", 443)){
Serial.println("Connection failed!");
return ESP_OK;
}
else {
Serial.println("Connected to server!");
// Make a HTTP request:
client.println("GET https://www.howsmyssl.com/a/check HTTP/1.0");
client.println("Host: www.howsmyssl.com");
client.println("Connection: close");
client.println();
}
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
WIFI_INFO("Headers received");
break;
}
}
while (client.available()) {
char c = client.read();
Serial.write(c);
}
client.stop();
}
return ESP_OK;
}
Debug Messages:
Starting connection to server...
[E][WiFiGeneric.cpp:685] hostByName(): DNS Failed for www.howsmyssl.com
[E][WiFiClientSecure.cpp:132] connect(): start_ssl_client: -1
Connection failed!
/home/matthew/.platformio/packages/framework-espidf/components/freertos/event_groups.c:560 (xEventGroupSetBits)- assert failed!
abort() was called at PC 0x40097280 on core 1
ELF file SHA256: 54be485e51b651e7
Backtrace: 0x4009c8e9:0x3ffbb250 0x4009cc6d:0x3ffbb270 0x40097280:0x3ffbb290 0x400d8e88:0x3ffbb2b0 0x400e7bc6:0x3ffbb2d0 0x400e7ccb:0x3ffbb2f0 0x400e8a05:0x3ffbb310 0x400f006d:0x3ffbb360 0x400f38b1:0x3ffbb3a0 0x400f92e6:0x3ffbb3c0 0x400e76ed:0x3ffbb3e0 0x400e776c:0x3ffbb400 0x4009736d:0x3ffbb430
#0 0x4009c8e9:0x3ffbb250 in invoke_abort at /home/matthew/.platformio/packages/framework-espidf/components/esp32/panic.c:155
#1 0x4009cc6d:0x3ffbb270 in abort at /home/matthew/.platformio/packages/framework-espidf/components/esp32/panic.c:172
#2 0x40097280:0x3ffbb290 in xEventGroupSetBits at /home/matthew/.platformio/packages/framework-espidf/components/freertos/event_groups.c:560 (discriminator 1)
#3 0x400d8e88:0x3ffbb2b0 in wifi_dns_found_callback(char const*, ip_addr const*, void*) at /home/matthew/.platformio/packages/framework-arduinoespressif32-src-c69fc9322995db5694e2741d307d9723/libraries/WiFi/src/WiFiGeneric.cpp:660
#4 0x400e7bc6:0x3ffbb2d0 in dns_call_found at /home/matthew/.platformio/packages/framework-espidf/components/lwip/lwip/src/core/dns.c:993
#5 0x400e7ccb:0x3ffbb2f0 in dns_correct_response at /home/matthew/.platformio/packages/framework-espidf/components/lwip/lwip/src/core/dns.c:1191
#6 0x400e8a05:0x3ffbb310 in dns_recv at /home/matthew/.platformio/packages/framework-espidf/components/lwip/lwip/src/core/dns.c:1338
#7 0x400f006d:0x3ffbb360 in udp_input at /home/matthew/.platformio/packages/framework-espidf/components/lwip/lwip/src/core/udp.c:404
#8 0x400f38b1:0x3ffbb3a0 in ip4_input at /home/matthew/.platformio/packages/framework-espidf/components/lwip/lwip/src/core/ipv4/ip4.c:778
#9 0x400f92e6:0x3ffbb3c0 in ethernet_input at /home/matthew/.platformio/packages/framework-espidf/components/lwip/lwip/src/netif/ethernet.c:186
#10 0x400e76ed:0x3ffbb3e0 in tcpip_thread_handle_msg at /home/matthew/.platformio/packages/framework-espidf/components/lwip/lwip/src/api/tcpip.c:180
#11 0x400e776c:0x3ffbb400 in tcpip_thread at /home/matthew/.platformio/packages/framework-espidf/components/lwip/lwip/src/api/tcpip.c:154
#12 0x4009736d:0x3ffbb430 in vPortTaskWrapper at /home/matthew/.platformio/packages/framework-espidf/components/freertos/port.c:143