Skip to content

Panic in AsyncTCP due to sudden WiFi disconnection #30

@hosseinaghaie

Description

@hosseinaghaie

IDE / Tooling

Arduino (IDE/CLI)

What happened?

Description
I'm encountering a panic in AsyncTCP (version 3.3.5) when the WiFi connection is suddenly lost during an active TCP session. The issue seems related to the tcp_sent function in lwIP and occurs intermittently when the connection is dropped unexpectedly.

I've used AsyncTCP in multiple functions across my project (including both HTTP requests and MQTT connections). Eventually, I was forced to replace those functions with esp-idf esp_http_client to prevent the panic. After switching to esp-idf's native client, the panic no longer occurred.

The environment is extremely noisy, and the network connection frequently drops due to interference. It feels like the DNS resolution fails or becomes unresponsive at times, but regardless of the cause, the device panics and resets.

Even though I check WiFi status (WiFi.status()) and use flags (onEvent SYSTEM_EVENT_STA_GOT_IP) to ensure the connection is stable before sending data, the panic still happens occasionally during the transmission process when the connection drops unexpectedly.

Additional Information:
The environment is noisy, and the network connection is highly unstable.
DNS resolution seems to fail or become unresponsive at times, which might contribute to the issue.
I tested the WiFi connection status (WiFi.status()) before sending data and used event handlers (onEvent SYSTEM_EVENT_STA_GOT_IP) to set flags for connection status.
Despite these checks, the panic still occurs intermittently during data transmission if the connection is lost mid-process.
After replacing AsyncTCP with esp_http_client from esp-idf, the problem disappeared completely.
This happens with both AsyncTCP and AsyncMqttClient.

this code work in other device (other location)) but in thsi location painic ocuure 4-5 times a day!

System Information
Board: ESP32-S3
ESP32 Arduino Core: 2.3.4
AsyncTCP Version: 3.3.5
ESP-IDF Version: 3.1.2

Stack Trace

PC: 0x40376711 0x4037670E 0x4037E0CD 0x40384D59 0x420629E7 0x42020C6E 0x42020CA4 0x42020FEE 0x42021023 0x4037EE16
0x00000000: ?? ??:0
0x40376711: panic_abort at esp_system/panic.c:463
0x4037670e: panic_abort at esp_system/panic.c:463
0x4037e0cd: esp_system_abort at esp_system_chip.c:92
0x40384d59: __assert_func at assert.c:80
0x420629e7: tcp_sent at lwip/src/core/tcp.c:2076 (discriminator 1)
0x42020c6e: AsyncClient::_error(signed char) at AsyncTCP.cpp:1055
0x42020ca4: AsyncClient::_s_error(void*, signed char) at AsyncTCP.cpp:1503
0x42020fee: _handle_async_event(lwip_tcp_event_packet_t*) at AsyncTCP.cpp:271
0x42021023: _async_service_task(void*) at AsyncTCP.cpp:294
0x4037ee16: vPortTaskWrapper at port.c:139

Minimal Reproductible Example (MRE)

test.txt

I confirm that:

  • I have read the documentation.
  • I have searched for similar discussions.
  • I have searched for similar issues.
  • I have looked at the examples.
  • I have upgraded to the lasted version of AsyncTCP.

Metadata

Metadata

Labels

Type: BugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions