You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, and first of all thank you for the great work on Rocket.
I've been following the discussion about native support for WebSockets on #90, and as far as I understood support for WebSockets has not been integrated into the Rocket API yet (I'm using v0.5-rc1). Is there any "hack" or manual solution that you know of for upgrading an opening handshake to an actual WebSocket connection in Rocket ?
While looking for a solution, I noticed that hyper supports upgrading an HTTP connection via the hyper::upgrade API (in hyper v0.14, this is done using the upgrade::on function). But in order to use that API, I believe I need access to a hyper::Request object to call upgrade::on() on. Is there any way to access the underlying hyper::Request object in a Rocket handler, or to convert a rocket::Request to a hyper::Request by any means ?
The text was updated successfully, but these errors were encountered:
Unfortunately, there isn't. I've oft contemplated whether Rocket should expose such a mechanism, for this reason and others, and time and time again, my conclusion is the same: no. Rocket strives to, above anything else, make it very difficult, ideally impossible, to make security and correctness mistakes. But exposing such a raw mechanism is fraught with pitfalls of every kind: security, correctness, performance, and usability. For this reason, we don't implement features unless we have a well thought out plan. Our support for web sockets will be the same.
Thankfully, @the10thWiz has been making stellar progress towards such an implementation (#1639). If you want to follow along with development discussions, join us on Matrix.
In the meantime, if you absolutely need websockets because, for instance, you need to respond to websocket requests from an external provider, then Rocket is unfortunately not an option at the moment. You can still use Rocket for non-websocket HTTP requests and run a websocket server on a separate port using another websocket library, however.
If you, however, you simply need real-time communication, then perhaps Server Sent Events are a good option. See the chat example as a fully developed application that makes use of SSE to implement a real-time, multi-room chat application.
Thank you for the answer. I'll be watching closely the evolution of the implementation on #1639. Unfortunately I cannot use SSE as this is an in-production project which already uses Websockets. I think I will stick with a Hyper-only solution for now, but I am looking forward to see this being released in Rocket. Keep up the great work !
Hello, and first of all thank you for the great work on Rocket.
I've been following the discussion about native support for WebSockets on #90, and as far as I understood support for WebSockets has not been integrated into the Rocket API yet (I'm using
v0.5-rc1
). Is there any "hack" or manual solution that you know of for upgrading an opening handshake to an actual WebSocket connection in Rocket ?While looking for a solution, I noticed that
hyper
supports upgrading an HTTP connection via thehyper::upgrade
API (in hyper v0.14, this is done using the upgrade::on function). But in order to use that API, I believe I need access to ahyper::Request
object to callupgrade::on()
on. Is there any way to access the underlyinghyper::Request
object in a Rocket handler, or to convert arocket::Request
to ahyper::Request
by any means ?The text was updated successfully, but these errors were encountered: