-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Https server hang on close_fn
#287
Comments
Has anyone used websockets where messages are sent out from another thread? Still not sure why it locks, but I wonder how I should change the logic for it to avoid locks. I could use |
Perhaps because the Detached senders are not really asynchronous. they seem asynchronous if you are sending very small packets through those. If the packet is bigger than a given size, they wait until they can push the whole packet. How they are implemented is very weird: they send via a hidden socket between them and the HTTP server. The HTTP server listens both on its regular socket as well as on this hidden socket (called "commands" socket). And then processes either content from the main socket (that's how you end up in So yeah, you should really be super careful when using mutexes which are locked both inside The long term solution is to get away from the ESP IDF HTTP server, as it is a weird architecture - single threaded, yet blocking, and replace it with a small, embedded, pure-Rust async server (which can be trivially turned into a blocking one using thread pools). This is started in edge-net, but it needs bugfixing. And async TLS support from ESP IDF which just got initiated. Another story if it would be possible/easy to implement this async support in |
Thanks for explanation! Now I use A while back I implemented whole async websocket stack
It was tricky and I even had to make |
Moving my investigation here espressif/esp-idf#11738
Summary: If there are multiple threads doing job when https server is running there is a chance it will hang. So far last thing that gets called is
close_fn
callback. It is reproduced if I put load on other thread when https call is madeIt hangs at
esp-idf-svc/src/http/server.rs
Line 447 in cf0b85c
Note: Not sure why websocket close handler is even called when I open Https endpoint
I think I found where it locks, but not sure why it would lock.
Stuck at
ws_listeners.lock().unwrap().remove(&session_id);
. I'm not sure how it managed to deadlock thoThe text was updated successfully, but these errors were encountered: