Skip to content

WiFiClient::flush() can get stuck indefinitely #4736

Closed
@tko

Description

@tko

Hardware:

Board: DOIT ESP32 DEVKIT V1
Core Installation version: 1.0.4
IDE name: Platform.io
Flash Frequency: Can't tell (Crystal is 40MHz?)
PSRAM enabled: Can't tell
Upload Speed: 921600
Computer OS: Mac OSX

Description:

After reading the http response line with WiFiClient::readBytesUntil() calling WiFiClient::flush() hangs indefinitely. Doesn't always happen, best guess is it depends on response length. First noticed with 204 No Content response from an influxdb server.

Sketch:

#include <WiFi.h>
#include <WiFiClient.h>

const char ssid[] = "FIXME";
const char pass[] = "FIXME";

void setup()
{
  Serial.begin(115200);

  WiFiClient client;
  WiFi.begin(ssid, pass);
  WiFi.waitForConnectResult();
  client.connect("httpbin.org", 80);
  client.printf("GET /status/200 HTTP/1.0\r\nHost: httpbin.org\r\n\r\n");

  auto res = client.readStringUntil('\n');
  Serial.println(res);

  client.flush();
  Serial.println("Done.");
}

void loop()
{
}

Debug Messages:

[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:381] _eventCallback(): STA IP: 192.168.1.2, MASK: 255.255.255.0, GW: 192.168.1.1
HTTP/1.1 204 NO CONTENT

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions