ESP32 WebServer can take 5 seconds to respond

As the subject says, I'm using the WebServer from the Esp32 core in the Arduino IDE, on a Node32MCUs.

My issue is that even though I call "handleClient()" regularly (in loop, with a delay of 20ms), the webserver hangs up.

According to the Chrome plugin I found, the delay is AFTER connect. So CONNECT is 100ms an REQUEST is 5700ms and then everything else is quick. But REQUEST takes forever, if that helps.

Other than calling handleClient() I'm not sure what I can reasonably do to improve things, and I'm already doing that!

How are you building up the response that the web server sends back to the browser ? Are you, for example, fetching data from an external source ? Posting your code would be a good idea.

do you send Content-length or use chunked encoding, so the browser knows the response is complete? do you use caching headers for static resources (html, css, js)?

Beat me to it! I found it somewhere else (someone else writing a web server had the same bug). Not setting content length was the issue!

Thanks!

some reading: https://github.com/jandrassy/StreamLib/blob/master/README.md#http-data-length