Bzzt
Bzzt

Reputation: 1054

Elm websockets with a Rust server

I'm wanting to use Elm for my web front end, and Rust for the server. But, I'm running into an issue where the websockets version from elm-socketio doesn't work with rust-websocket. As far as I can tell elm-socketio has websockets version "2.0.0" (a string I found searching socketio.js that comes with elm-socketio), while rust-websocket has version "13". In Rust an exception happens when the mismatched version is received. I commented out the version check just to see what would happen, and I get this:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RequestError("Missing Sec-WebSocket-Key header")', src/libcore/result.rs:731

So I guess my question is can these two be made to work with each other without significant work? Is there really a version 2.0.0 of websockets, and is that different from RFC6455 which is what rust-websocket refers to (and has version "13")?

Upvotes: 4

Views: 2063

Answers (1)

Mark Bolusmjak
Mark Bolusmjak

Reputation: 24419

It seems socket.io has it's own protocol (see https://github.com/socketio/socket.io-protocol). It's confusing because

"The socket.io protocol can be delivered over a variety of transports."

Websockets are a possible transport layer for socket.io. https://github.com/socketio/socket.io-protocol#transport

You need to find a rust-socket.io library.

Upvotes: 5

Related Questions