rust-websocket-lite icon indicating copy to clipboard operation
rust-websocket-lite copied to clipboard

Websocket server support

Open 1tgr opened this issue 5 years ago • 4 comments

  • ~impl Encoder for UpgradeCodec~ probably not, as the web framework will handle sending of headers for the Upgrade request
  • Integration with relevant web framework(s):
  • [x] hyper
  • [ ] rocket
  • [ ] actix-web

Integration to include Autobahn conformance testing and example code.

1tgr avatar Dec 02 '19 19:12 1tgr

I just realized this crate is currently aimed towards WebSocket clients more so than servers. Would it be relatively easy to have the encoder accept some sort of control on whether or not it masks messages? I'm building an MQTT server which works with WebSocket connections using this crate, and it's almost working aside from the server sending masked messages which the browser rejects.

I can help in writing it if you have a particular design you're after.

bschwind avatar Feb 09 '20 17:02 bschwind

@1tgr I hacked together something just to see if I could get it working:

https://github.com/1tgr/rust-websocket-lite/compare/master...bschwind:master

Seems to function correctly! The change I made is technically a breaking one so I wouldn't recommend using it verbatim, but something along those lines would be helpful to be able to use this crate in a server setting. Thanks for writing it!

bschwind avatar Feb 10 '20 13:02 bschwind

Thanks @bschwind, this is helpful. Do you have anything that integrates this library with a full web server? There is this example in hyper/examples/upgrade.rs, but it's not exactly at the point where it's plug-and-play.

1tgr avatar Feb 23 '20 18:02 1tgr

@1tgr Unfortunately I don't, I'm using it for an MQTT-over-WebSockets broker so I only needed a subset of all WebSocket functionality. You can see its usage here:

https://github.com/bschwind/mqtt-broker/blob/dd5ff38985aa242ccd6e2e126a22b5ce312dcd46/mqtt-v5-broker/src/main.rs#L44-L60

bschwind avatar Feb 24 '20 03:02 bschwind