I'm serving chunked mjpeg from an esp32-cam (thinkertoy). I know my code can't handle more than one client request at a time. But I'd at least like to be able to close a browser window showing the video and then have the server cleanly close the http connection. Then another browser could start viewing the video.
Right now, when the client disappears, the server hangs in a httpd_resp_send_chunk call and never returns. So there is no way inside the handler to close the stream with p_send_chunk(req, NULL, 0);
I tried saving the req pointer globally and then doing the p_send_chunk(req, NULL, 0); from an outside loop timeout but that crashed the esp32 (not a big surprise).
Any ideas?
Server hangs inside httpd_resp_send_chunk when client goes away
Re: Server hangs inside httpd_resp_send_chunk when client goes away
It occurs to me that having the send_chunk call time out would be ideal. Is there a way to set a timeout for send_chunk or a tcp connection in general? Is there a way to set a timeout for a raw response? Could I code the chunk responses using raw or is raw hard-wired to close the response?
Is the source code for the espressif http server available for me to look at?
Is the source code for the espressif http server available for me to look at?
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: Server hangs inside httpd_resp_send_chunk when client goes away
Yes it is, in esp-idf/components/esp_http_server/src/ , specifically the code you're looking for is in httpd_txrx.c
Re: Server hangs inside httpd_resp_send_chunk when client goes away
Thanks.
I found different code for the esp32 cameras. It uses WebServer inside tasks without chunking and the code not only handles disconnects but allows up to 10 connections at once. That gets me around the send chunk hangups, assuming it works. I'm going to give that a try.
I'm curious about the difference between WebServer and esp_http_server. I'm going to google that.
I found different code for the esp32 cameras. It uses WebServer inside tasks without chunking and the code not only handles disconnects but allows up to 10 connections at once. That gets me around the send chunk hangups, assuming it works. I'm going to give that a try.
I'm curious about the difference between WebServer and esp_http_server. I'm going to google that.
Who is online
Users browsing this forum: No registered users and 197 guests