Weylus icon indicating copy to clipboard operation
Weylus copied to clipboard

Consider replacing websocket-rs and hyper with warp

Open H-M-H opened this issue 3 years ago • 1 comments

Unfortunately the websocket crate is not properly maintained anymore, citing their readme:

Note that this particular library is based on obsolete dependencies (Hyper 0.10, Tokio 0.1), so is a poor choice for new projects. You are adviced to use other Websocket libraries.

I chose the websocket-rs crate at the time because I liked it's messaging API best, specifically it's possible to create a new Message struct without copying the data to be sent, a reference like &[u8] is fine. I also considered tungstenite, but unfortunately messages there own their data. This means every video frame would have to be pointlessly copied in order to send it. See for example https://github.com/snapview/tungstenite-rs/issues/96 for further discussion on this.

The latency penalty for copying the video frames is probably not too bad but I'd like to verify that with some benchmarks. Possibly tungstenite is even faster than websocket-rs due to other reasons. To my knowledge there is currently no other usable websockets library for rust available.

And this is where warp comes into play. It's based on hyper and supports websockets via tungstenite. Additionally it allows listening on a single port for the web as well as the websocket connection. My hope is that using warp may simplify the code a little while getting rid of the outdated websocket-rs crate.

H-M-H avatar Aug 04 '22 15:08 H-M-H

axum seems to be another possibility.

H-M-H avatar Aug 25 '22 21:08 H-M-H