esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

hostByName(): DNS Failed with ethernet connection, esphome restarts after this error #5039

Open zdenekchobot opened 11 months ago

zdenekchobot commented 11 months ago

The problem

<0x1b>[0;35m[C][http_request:014]: HTTP Request:<0x1b>[0m <0x1b>[0;35m[C][http_request:015]: Timeout: 10000ms<0x1b>[0m <0x1b>[0;35m[C][http_request:016]: User-Agent: esphome/wt32-eth01<0x1b>[0m <0x1b>[0;35m[C][http_request:017]: Follow Redirects: 1<0x1b>[0m <0x1b>[0;35m[C][http_request:018]: Redirect limit: 3<0x1b>[0m **[ 5932][E][WiFiGeneric.cpp:1438] hostByName(): DNS Failed for e9553n-2hakkm.tmep.cz <0x1b>[0;36m[D][main:178]: Response status: -1, Durat assert failed: xEventGroupSetBits event_groups.c:596 (xEventGroup)** Backtrace:0x400836bd:0x3ffb35f00x4008c209:0x3ffb3610 0x400916cd:0x3ffb3630 0x4008c726:0x3ffb3760 0x40145a98:0x3ffb3780 0x400f747d:0x3ffb37a0 0x400f7539:0x3ffb37d0 0x400f7cc3:0x3ffb37f0 0x400fee69:0x3ffb3850 0x401020bf:0x3ffb38a0 0x401063e2:0x3ffb38d0 0x400f7179:0x3ffb38f0 ### Which version of ESPHome has the issue? ESPHome 2023.10.3 ### What type of installation are you using? Home Assistant Add-on ### Which version of Home Assistant has the issue? Home Assistant 2023.10.5 ### What platform are you using? ESP32 ### Board wt32-eth01 ### Component causing the issue http_request ### Example YAML snippet ```yaml esphome: name: wt32-eth01 friendly_name: wt32-eth01 esp32: board: wt32-eth01 framework: type: arduino # Enable logging logger: level: debug # Enable Home Assistant API api: encryption: key: "W8apyx8y1zxepBWBO22U4s8xyX0OpjO/P7+2KuRpHqg=" ota: password: "179fde7cc36a876fd7651bc71e5c84b5" ethernet: type: LAN8720 mdc_pin: GPIO23 mdio_pin: GPIO18 clk_mode: GPIO0_IN phy_addr: 1 power_pin: GPIO16 http_request: useragent: esphome/wt32-eth01 timeout: 10s id: req001 interval: - interval: 10s then: - http_request.get: url: http://e9553n-2hakkm.tmep.cz/?temp=24.56 # headers: # Content-Type: application/json # verify_ssl: false on_response: then: - logger.log: format: 'Response status: %d, Duration: %u ms, Body: %s' args: - status_code - duration_ms - id(req001).get_string() ``` ### Anything in the logs that might be useful for us? ```txt <0x1b>[0;32m[I][logger:326]: Log initialized<0x1b>[0m <0x1b>[0;35m[C][ota:473]: There have been 2 suspected unsuccessful boot attempts.<0x1b>[0m <0x1b>[0;36m[D][esp32.preferences:114]: Saving 1 preferences to flash...<0x1b>[0m <0x1b>[0;36m[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed<0x1b>[0m <0x1b>[0;32m[I][app:029]: Running through setup()...<0x1b>[0m <0x1b>[0;35m[C][ethernet:028]: Setting up Ethernet...<0x1b>[0m <0x1b>[0;33m[W][http_request:037]: HTTP Request failed; Not connected to network<0x1b>[0m <0x1b>[0;32m[I][ethernet:137]: Starting ethernet connection<0x1b>[0m <0x1b>[0;32m[I][ethernet:148]: Connected via Ethernet!<0x1b>[0m <0x1b>[0;35m[C][ethernet:353]: IP Address: 0.0.0.0<0x1b>[0m <0x1b>[0;35m[C][ethernet:354]: Hostname: 'wt32-eth01'<0x1b>[0m <0x1b>[0;35m[C][ethernet:355]: Subnet: 0.0.0.0<0x1b>[0m <0x1b>[0;35m[C][ethernet:356]: Gateway: 0.0.0.0<0x1b>[0m <0x1b>[0;35m[C][ethernet:361]: DNS1: 192.168.254.5<0x1b>[0m <0x1b>[0;35m[C][ethernet:362]: DNS2: 0.0.0.0<0x1b>[0m <0x1b>[0;35m[C][ethernet:382]: MAC Address: 24:DC:C3:86:B6:E3<0x1b>[0m <0x1b>[0;35m[C][ethernet:387]: Is Full Duplex: YES<0x1b>[0m <0x1b>[0;35m[C][ethernet:392]: Link Speed: 100<0x1b>[0m <0x1b>[0;35m[C][ota:097]: Over-The-Air Updates:<0x1b>[0m <0x1b>[0;35m[C][ota:098]: Address: wt32-eth01.local:3232<0x1b>[0m <0x1b>[0;35m[C][ota:101]: Using Password.<0x1b>[0m <0x1b>[0;33m[W][ota:107]: Last Boot was an unhandled reset, will proceed to safe mode in 8 restarts<0x1b>[0m <0x1b>[0;35m[C][api:025]: Setting up Home Assistant API server...<0x1b>[0m <0x1b>[0;32m[I][app:062]: setup() finished successfully!<0x1b>[0m <0x1b>[0;32m[I][app:102]: ESPHome version 2023.10.3 compiled on Oct 26 2023, 22:40:54<0x1b>[0m <0x1b>[0;35m[C][logger:416]: Logger:<0x1b>[0m <0x1b>[0;35m[C][logger:417]: Level: DEBUG<0x1b>[0m <0x1b>[0;35m[C][logger:418]: Log Baud Rate: 115200<0x1b>[0m <0x1b>[0;35m[C][logger:420]: Hardware UART: UART0<0x1b>[0m <0x1b>[0;35m[C][ethernet:221]: Ethernet:<0x1b>[0m <0x1b>[0;35m[C][ethernet:353]: IP Address: 192.168.254.167<0x1b>[0m <0x1b>[0;35m[C][ethernet:354]: Hostname: 'wt32-eth01'<0x1b>[0m <0x1b>[0;35m[C][ethernet:355]: Subnet: 255.255.255.0<0x1b>[0m <0x1b>[0;35m[C][ethernet:356]: Gateway: 192.168.254.1<0x1b>[0m <0x1b>[0;35m[C][ethernet:361]: DNS1: 192.168.254.5<0x1b>[0m <0x1b>[0;35m[C][ethernet:362]: DNS2: 0.0.0.0<0x1b>[0m <0x1b>[0;35m[C][ethernet:382]: MAC Address: 24:DC:C3:86:B6:E3<0x1b>[0m <0x1b>[0;35m[C][ethernet:387]: Is Full Duplex: YES<0x1b>[0m <0x1b>[0;35m[C][ethernet:392]: Link Speed: 100<0x1b>[0m <0x1b>[0;35m[C][ethernet:224]: Power Pin: 16<0x1b>[0m <0x1b>[0;35m[C][ethernet:226]: MDC Pin: 23<0x1b>[0m <0x1b>[0;35m[C][ethernet:227]: MDIO Pin: 18<0x1b>[0m <0x1b>[0;35m[C][ethernet:228]: Type: LAN8720<0x1b>[0m <0x1b>[0;35m[C][ethernet:229]: PHY addr: 1<0x1b>[0m <0x1b>[0;35m[C][mdns:115]: mDNS:<0x1b>[0m <0x1b>[0;35m[C][mdns:116]: Hostname: wt32-eth01<0x1b>[0m <0x1b>[0;35m[C][ota:097]: Over-The-Air Updates:<0x1b>[0m <0x1b>[0;35m[C][ota:098]: Address: wt32-eth01.local:3232<0x1b>[0m <0x1b>[0;35m[C][ota:101]: Using Password.<0x1b>[0m <0x1b>[0;33m[W][ota:107]: Last Boot was an unhandled reset, will proceed to safe mode in 8 restarts<0x1b>[0m <0x1b>[0;35m[C][api:138]: API Server:<0x1b>[0m <0x1b>[0;35m[C][api:139]: Address: wt32-eth01.local:6053<0x1b>[0m <0x1b>[0;35m[C][api:141]: Using noise encryption: YES<0x1b>[0m <0x1b>[0;35m[C][http_request:014]: HTTP Request:<0x1b>[0m <0x1b>[0;35m[C][http_request:015]: Timeout: 10000ms<0x1b>[0m <0x1b>[0;35m[C][http_request:016]: User-Agent: esphome/wt32-eth01<0x1b>[0m <0x1b>[0;35m[C][http_request:017]: Follow Redirects: 1<0x1b>[0m <0x1b>[0;35m[C][http_request:018]: Redirect limit: 3<0x1b>[0m [ 5932][E][WiFiGeneric.cpp:1438] hostByName(): DNS Failed for e9553n-2hakkm.tmep.cz <0x1b>[0;36m[D][main:178]: Response status: -1, Durat assert failed: xEventGroupSetBits event_groups.c:596 (xEventGroup) Backtrace:0x400836bd:0x3ffb35f00x4008c209:0x3ffb3610 0x400916cd:0x3ffb3630 0x4008c726:0x3ffb3760 0x40145a98:0x3ffb3780 0x400f747d:0x3ffb37a0 0x400f7539:0x3ffb37d0 0x400f7cc3:0x3ffb37f0 0x400fee69:0x3ffb3850 0x401020bf:0x3ffb38a0 0x401063e2:0x3ffb38d0 0x400f7179:0x3ffb38f0 ``` ### Additional information DNS works ok. With wifi component/connection everything works perfectly.
ssieb commented 11 months ago

The crash is most likely because you're trying to access id(req001).get_string() when the request failed.

zdenekchobot commented 11 months ago

The crash is most likely because you're trying to access id(req001).get_string() when the request failed.

The crash probably occurs earlier. After removing "id(req001).get_string()", the behavior is the same.

<0x1b>[0;35m[C][http_request:014]: HTTP Request:<0x1b>[0m <0x1b>[0;35m[C][http_request:015]: Timeout: 10000ms<0x1b>[0m <0x1b>[0;35m[C][http_request:016]: User-Agent: esphome/wt32-eth01<0x1b>[0m <0x1b>[0;35m[C][http_request:017]: Follow Redirects: 1<0x1b>[0m <0x1b>[0;35m[C][http_request:018]: Redirect limit: 3<0x1b>[0m <0x1b>[0;36m[D][api:102]: Accepted 192.168.254.10<0x1b>[0m <0x1b>[0;36m[D][api.connection:1032]: ESPHome Logs 2023.10.3 (192.168.254.10): Connected successfully<0x1b>[0m [ 7996][E][WiFiGeneric.cpp:1438] hostByName(): DNS Failed for [e9553n-2hakkm.tmep.cz](http://e9553n-2hakkm.tmep.cz/) <0x1b>[0;36m[D][main:176]: Response status: -1, Du assert failed: xEventGroupSetBits event_groups.c:596 (xEventGroup) Backtrace:0x400836bd:0x3ffb35f00x4008c209:0x3ffb3610 0x400916cd:0x3ffb3630 0x4008c726:0x3ffb3760 0x40145354:0x3ffb3780 0x400f6f1d:0x3ffb37a0 0x400f6fd9:0x3ffb37d0 0x400f7763:0x3ffb37f0 0x400fe909:0x3ffb3850 0x40101b5f:0x3ffb38a0 0x40105e82:0x3ffb38d0 0x400f6c19:0x3ffb38f0
ssieb commented 11 months ago

What's the new on_response: section? Can you connect this device directly to esphome so that the stack trace will get decoded?

zdenekchobot commented 11 months ago

What's the new on_response: section? on_response: then:

  • logger.log: format: 'Response status: %d, Duration: %u ms,' args:
  • status_code
  • duration_ms

Can you connect this device directly to esphome so that the stack trace will get decoded? I can - in the evening. But what exactly do you mean? The board is connected via ethernet (cable) to the LAN and managed by the esphome plug-in in HA.

ssieb commented 11 months ago

Somehow you are getting serial logs now. But you need esphome to read those serial logs so that it can decode the stack trace. We need that to find out what's crashing.

zdenekchobot commented 11 months ago

Somehow you are getting serial logs now. But you need esphome to read those serial logs so that it can decode the stack trace. We need that to find out what's crashing.

image or image or something else?

ssieb commented 11 months ago

The first one, but the ESP needs to be plugged into the system running esphome/HA. You need to choose the option for "device plugged into the system running esphome".

zdenekchobot commented 11 months ago

The first one, but the ESP needs to be plugged into the system running esphome/HA. You need to choose the option for "device plugged into the system running esphome".

Thank you, I will send the log in the afternoon or evening

zdenekchobot commented 11 months ago

The first one, but the ESP needs to be plugged into the system running esphome/HA. You need to choose the option for "device plugged into the system running esphome".

Log attached logs_wt32-eth01.txt

ssieb commented 11 months ago

It's all internal to lwip and freertos:

[11:13:51][  5369][E][WiFiGeneric.c
[11:13:51]assert failed: xEventGroupSetBits event_groups.c:596 (xEventGroup)
[11:13:51]
[11:13:51]
[11:13:51]Backtrace:0x400836bd:0x3ffb35f00x4008c209:0x3ffb3610 0x400916cd:0x3ffb3630 0x4008c726:0x3ffb3760 0x40148154:0x3ffb3780 0x400f9c19:0x3ffb37a0 0x400f9cd5:0x3ffb37d0 0x400fa45f:0x3ffb37f0 0x40101605:0x3ffb3850 0x4010485b:0x3ffb38a0
 0x40108b7e:0x3ffb38d0 0x400f9915:0x3ffb38f0 
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x400836bd: panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
WARNING Decoded 0x4008c209: esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:128
WARNING Decoded 0x400916cd: __assert_func at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/assert.c:85
WARNING Decoded 0x4008c726: xEventGroupSetBits at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/event_groups.c:597 (discriminator 1)
WARNING Decoded 0x40148154: wifi_dns_found_callback(char const*, ip_addr const*, void*) at /data/cache/platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.cpp:1413
WARNING Decoded 0x400f9c19: dns_call_found at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/dns.c:999
WARNING Decoded 0x400f9cd5: dns_correct_response at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/dns.c:1197
WARNING Decoded 0x400fa45f: dns_recv at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/dns.c:1364
WARNING Decoded 0x40101605: udp_input at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/udp.c:404
WARNING Decoded 0x4010485b: ip4_input at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/ipv4/ip4.c:794
WARNING Decoded 0x40108b7e: ethernet_input at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/netif/ethernet.c:186
WARNING Decoded 0x400f9915: tcpip_thread_handle_msg at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/api/tcpip.c:180
 (inlined by) tcpip_thread at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/api/tcpip.c:154
zdenekchobot commented 11 months ago

It's all internal to lwip and freertos:

[11:13:51][  5369][E][WiFiGeneric.c
[11:13:51]assert failed: xEventGroupSetBits event_groups.c:596 (xEventGroup)
[11:13:51]
[11:13:51]
[11:13:51]Backtrace:0x400836bd:0x3ffb35f00x4008c209:0x3ffb3610 0x400916cd:0x3ffb3630 0x4008c726:0x3ffb3760 0x40148154:0x3ffb3780 0x400f9c19:0x3ffb37a0 0x400f9cd5:0x3ffb37d0 0x400fa45f:0x3ffb37f0 0x40101605:0x3ffb3850 0x4010485b:0x3ffb38a0
 0x40108b7e:0x3ffb38d0 0x400f9915:0x3ffb38f0 
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x400836bd: panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
WARNING Decoded 0x4008c209: esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:128
WARNING Decoded 0x400916cd: __assert_func at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/assert.c:85
WARNING Decoded 0x4008c726: xEventGroupSetBits at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/event_groups.c:597 (discriminator 1)
WARNING Decoded 0x40148154: wifi_dns_found_callback(char const*, ip_addr const*, void*) at /data/cache/platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiGeneric.cpp:1413
WARNING Decoded 0x400f9c19: dns_call_found at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/dns.c:999
WARNING Decoded 0x400f9cd5: dns_correct_response at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/dns.c:1197
WARNING Decoded 0x400fa45f: dns_recv at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/dns.c:1364
WARNING Decoded 0x40101605: udp_input at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/udp.c:404
WARNING Decoded 0x4010485b: ip4_input at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/ipv4/ip4.c:794
WARNING Decoded 0x40108b7e: ethernet_input at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/netif/ethernet.c:186
WARNING Decoded 0x400f9915: tcpip_thread_handle_msg at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/api/tcpip.c:180
 (inlined by) tcpip_thread at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/api/tcpip.c:154

😒 How to fix it?

github-actions[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Tarik2142 commented 18 hours ago

not stale, i have same error