-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web server refuses connections although max socket connections not exceeded (IDFGH-8004) #9514
Comments
@ESP-YJM thank you! I tried that and it appears to be working properly now after some brief testing. |
@ESP-YJM, IMO |
@chipweinberger Yes, that's a good idea. Add |
Great to see that merged, @ESP-YJM! Is there a reason we don't care about the return value of setsockop? Please see my comment: #9395 (comment) |
I am using ESP-IDF v4.4.1 on an ESP32-Pico Kit v4.1.
My application has a REST API server which has been working well. I wanted to add a WebSocket interface, using the ESP32 as a WebSocket server, so I added a handler for it, in addition to my REST API path handlers.
Here's the handler function:
In the javascript client, when the page is loaded, I open the WebSocket:
The WebSocket is basically working, but here's the problem: if I reload the page a number of times, the server soon stops responding. I have my maximum sockets set to 16 in my SDK config (which limits the actual number to 13 sockets in the code). But I do not have 13 sockets open, at least not based upon what I'm seeing. The following log is generated using handlers for the
open_fn
andclose_fn
events for the server:From this log, when the client page is initially loaded, several sockets are opened, including the websocket. Each subsequent reload of the page generally closes the prior WebSocket and opens one new one in its place. I don't see a net gain in open sockets here. Nonetheless, after a few reloads, the ESP32 server stops responding and won't accept any more connections. This problem gets worst and happens much sooner if I add support for more WebSocket clients. In order to remedy this issue, I have to reboot the ESP32. Waiting for sockets to timeout and close does not resolve the issue.
The text was updated successfully, but these errors were encountered: