-
Hey everyone, Seeing that Rust now has stable async traits (🎉🎉) got me wondering if there are any plans to get async support into websocket handlers? It would certainly make our lives much easier. I really like having a combined REST-API with websockets endpoints in one go. And all the extras like protobufs support, would make a switch to an architecture based on actix-web for REST + tokio-tungstenite for websockets, a bit of a pain. Keen to hear your thoughts! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
If you're using actix's actor-based websocket handler, you can use async methods, and you shouldn't use block_on in an actor context. https://docs.rs/actix/latest/actix/type.ResponseFuture.html |
Beta Was this translation helpful? Give feedback.
-
(copying from Discord for future wanderers) There's the the That combined with https://ryhl.io/blog/actors-with-tokio/ will probably be a better system than using actix actors. |
Beta Was this translation helpful? Give feedback.
If you're using actix's actor-based websocket handler, you can use async methods, and you shouldn't use block_on in an actor context.
https://docs.rs/actix/latest/actix/type.ResponseFuture.html
https://docs.rs/actix/latest/actix/type.ResponseActFuture.html