me-no-dev / ESPAsyncWebServer

Async Web Server for ESP8266 and ESP32
3.7k stars 1.21k forks source link

ACK Timeout is triggered, but I don't know why #1388

Open WeeJeWel opened 6 months ago

WeeJeWel commented 6 months ago

I am using Node.js eventsource with the AsyncEventSource plugin.

This works most of the time, but it some cases (mostly after doing a heavy POST request with some ArduinoJson), the timeout is triggered. This results in the client being disconnected.

The same happens with curl http://192.168.0.2/events.

My workaround is this:

    http_events = new AsyncEventSource("/events");
    http_events->onConnect([](AsyncEventSourceClient *client) {
      debug("Client Connected");

      // Disable ACK Timeouts. I don't know why these trigger,
      // but they happen after doing a POST request — most of the time.
      // Disabling timeouts altogether seems to work fine.
      client->client()->onTimeout([](void *arg, AsyncClient *client, unsigned int time) {
        debug("Client ACK Timeout");
      });

This works, but of course isn't as elegant. I am not sure whether this is a bug, but wanted to let the developers know anyway. Maybe it's a known issue, or they can easily understand why it goes wrong.