-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add WebSocket support for RemoteHttpPlugin #16403
base: main
Are you sure you want to change the base?
Conversation
You added a new feature but didn't add a description for it. Please update the root Cargo.toml file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this as off-by-default :) Seems generally useful. Agree on cutting out the tokio dep later though.
You added a new feature but didn't update the readme. Please run |
Objective
BRP currently has a HTTP transport implementation, including watching requests using SSE (server-sent events).
While SSE can be great, especially when combined with HTTP/2, it has a significant limitation when used with HTTP/1.1. The browser will limit the amount of concurrent requests to a very low number.
There are other nice options today like WebTransport, but all of them (AFAIK) suffer from being limited to secure (HTTPS) connections only. Same thing applies to SSE over HTTP/2.
To keep the developer-friendly experience of not needing a certificate, while also allowing more concurrent watches, WebSocket seems like the only viable option.
Solution
RemoteHttpPlugin
usingtungstenite
. This way the connection uses the same endpoint (host/port) as the HTTP requests.Text
messages serialized to JSON, following the JSON RPC 2.0 format of BRP.id
field in JSON RPC 2.watch_id
andbevy/unwatch
#16407remote_websocket
(non-default)http
feature optional and only included when the feature is enabled.Testing
server
example and used a web based tool to test both complete and watched requests, as well as batched requests.server
/client
examples to ensure HTTP still works.To test it
Run the
server
example with WebSocket enabled:Follow-up
Reduce dependency footprint, potentially by:
hyper-tungstenite
with custom implementation. It is a tiny library, but adds a (non-optional)tokio
dependency which should not be needed.futures-util
can be replaced withsmol
alternatives.