Open marciot opened 3 years ago
Hello, I think this is an inherent "problem" of this webserver implementation - it runs all requests in one loop. If one of the requests does not end, all other requests are blocked and time out. Although this implementation is a very nice and fast webserver it does not really work "asynchronous". But for Arduino on ESP32 I currently do not know a better one. If you can/want to use ESP-IDF directly you could check if this is something which would fit your needs. It works totally asynchronous, is (high-level) cpp, non-Arduino and quite stable. Unfortunately for some reason this solution works a little bit slow...
Describe the bug
Maybe not a bug, more of a limitation of the current implementation and a feature request for a way around this problem.
I have created a handler for streaming MJPEG video via a multipart form. This handler serves data continuously until the client closes the connection. I've noticed that while a stream is active, all other connections to the web server timeout.
At first, I was confused by this, because ESP32 is supposed to allow multiple connections, but it appears as if this means is that while it can allow multiple sequential requests over an open connection, only one request handler can run at a time.
My question is whether it would be possible to have a special handler for HTTP streams. Since esp32_https_server allows websockets, which also run continuously, I assume it is theoretically possible, but my guess is that it would need to be a special type of connection object for HTTP streams, just like WebsocketHandler. The difference would be where instead of having a single handler function that is called once, there are multiple functions, one for setting up the connection, one for emitting each "frame" in the stream, and a last for cleaning up.
How To Reproduce
Create a handler that streams video as a multipart form:
Expected Behavior
The user should be able to connect to "http//esp32_server/capture.mjpg", leave that window open, and still be able to access other resources on the web server.
Actual Behavior
Once the user makes a connection to "http//esp32_server/capture.mjpg", all accesses to the server time out until that window is closed.
ESP32 Module Please provide specifications of your module
Software (please complete the following information if applicable)
Additional context Add any other context about the problem here.