Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Extremely long response time / connection timeouts #17

Closed
tpalaz opened this issue Oct 16, 2020 · 1 comment
Closed

Extremely long response time / connection timeouts #17

tpalaz opened this issue Oct 16, 2020 · 1 comment
Labels
Support Library support

Comments

@tpalaz
Copy link

tpalaz commented Oct 16, 2020

Hello!
I would like to share a problem which I have been experiencing now for roughly a week. On my ESP8266, the AsyncWebServer is often responding at a rate which is extremely slow (25s - up to 3 minutes). The sketch being used is a modified example (specifically, the DRD-Esp8266 Webserver). Here is the relevant code for webserver setup:

    webServer.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
       request->send(200, "text/plain", "hello there!");
    });

    webServer.on("/all", [](AsyncWebServerRequest * request)
    {
      String json('{');
      json += "\"heap\":" + String(ESP.getFreeHeap());
      json += ", \"analog\":" + String(analogRead(A0));
      json += ", \"gpio\":" + String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
      json += "}";
      request->send(200, "text/json", json);
      json.clear();
    });
    webServer.begin();

When connecting to either "/" or "/all", sometimes the response is extremely quick (3ms) or incredibly slow / times out.
Here are the request headers (they are the same for both pages, and do not change if the response is slow/fast)

GET / HTTP/1.1
Host: 192.168.1.69
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9

Similarily, here is the respone:

HTTP/1.1 200 OK
Content-Length: 12
Content-Type: text/plain
Connection: close
Accept-Ranges: none

The timing console shows that the initial connection hangs (anywhere from instant to 10+ seconds), and then the Waiting(TTFB) hangs for a long time too (10ms --- 5+ minutes).

This happens randomly, and there is no indication that it is caused by memory. The heap available when making requests is consistently at ~32872, and at lowest drops to about 2.9.

If the request does not got through, this is the error:
(failed)net::ERR_CONNECTION_TIMED_OUT

There are no files being served, nothing.
Interestingly, the captive portal almost always works and is always pretty quick to respond.
I'm really confused what could be causing this. Iv'e tested on 2 seperate ESP8266 and both share similar results. As always, I am loving the library.

@khoih-prog
Copy link
Owner

Again thanks for your nice words about the library.

I've just retested the Async_ESP_FSWebServer_DRD and didn't find out any issue as mentioned. Even the files are loaded from SPIFFS/LittleFS, the response time is very quick.

Selection_585

I suggest you start from scratch, move ahead methodologically until starting experiencing problem, then find out why.

  1. Start from the original Async_ESP_FSWebServer_DRD
  2. Add/replace your code step-by-step and test every time OK until moving ahead

I'm afraid without the same code and settings environment (networks, hardware, routers, etc. ), no one can duplicate the issue and help you.

Remember to use the IP address instead of the mDNS name to avoid unreliability of the mDNS.

For example: using 192.168.2.186/edit instead of http://async-esp8266fs.local/edit

@khoih-prog khoih-prog added the Support Library support label Oct 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Support Library support
Projects
None yet
Development

No branches or pull requests

2 participants