Skip to content

Sockets get stuck in drain-wait state on ESP32 in AP mode #2297

Open
@GaryOtt

Description

@GaryOtt

EDIT: Scroll down to #2297 (comment) for later test code.


A failure to pipe data to a TCP socket can occur on the ESP32 build. I have not tested UDP sockets.

The socket may get stuck in a drain wait condition for tens of seconds, sometimes minutes, sometimes seemingly infinitely. This continues in ESP-IDF 3.3.6 based builds.


Details of my test:

test_code.zip

In this test, the WiFi is in AP mode and Espruino is running a web server (esp32_code.js). A script running on my development machine (test_http.js) sends HTTP requests repeatedly. Requests are sent 5 seconds after the completion of the last. The content of a file loaded from Storage is piped to the HTTP response.

The web server code keeps a check on the progress of requests and logs a timeout after 30 seconds of inactivity. When everything works fine, there is a continuous stream of data piped to the client but as the below video shows, sometimes it just stops for minutes at a time.

Results: https://youtu.be/4FyuYrBg8ck

0.00 Script is already uploading to ESP32.
0.23 Upload completes.
0.29 MacBook is connected to the WiFi AP hosted by the ESP32.
0.30 I start the node script to make repeated HTTP requests.
0.36 First HTTP request is completed and we see 'Finished' logged.
0.41 Second HTTP request made.
0.44 Some very minor pauses seen.
0.46 Second HTTP completes.
(third, fourth and fifth requests complete perfectly).
1.20 We get some significant pauses.
1.57 30 second timeout elapses.
3.00 Rest of page delivered.
3.13 More pauses.
3.43 30 second timeout elapses.
3.54 End

Metadata

Metadata

Assignees

No one assigned

    Labels

    ESP32This is only a problem on ESP32-based devices

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions