Skip to content

ehsanul/rust-ws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-ws

rust-ws is a really basic, and incomplete web sockets library for Rust. Text and binary messages are supported, and only servers are supported for now. Clients (and other support) coming soon. See the Todo section below for what's missing, there's a lot to do!

Build

You need to have a bleeding-edge rustc already in your PATH first, though this repository may be somewhat behind master at times. Cargo will fetch other dependancies.

git clone [email protected]:ehsanul/rust-ws.git
cd rust-ws
cargo build
cargo test # builds examples in target/examples

Examples

See the echo server example under the examples/ directory for basic usage.

Running The Autobahn Test Suite

To run the Autobahn test suite, first install it using these instructions. Then run the example echo server (it uses port 8001):

./target/examples/echo-server

Then, in another terminal, run the tests like so:

wstest --mode=fuzzingclient --spec=fuzzingclient.json

Test results will be generated in a sub-directory called reports.

Todo

So much to do.

Code

  • Cleanly drop associated tasks - ie when the read task fails, the write task ought to be fail!-ed, even if it is waiting on a separate Chan read, and vice-versa. Right now, this is not handled properly, leading to a memory leak for every new ws connection.
  • ws clients. Right now, it assumes a ws server, but a lot of the code is common to both clients and servers. factor that out and create a WebSocketClient trait.
  • Get closer to RFC 6455 in terms of what connections are accepted and what are rejected. right now, some invalid things are allowed. eg there's no check for Connection: Upgrade header, or the Sec-WebSocket-Version: 13 header.
  • Unit tests.
  • Benchmarks, comparisons, optimization.

Missing Support

  • Fragmented messages
  • Pass 100% of http://autobahn.ws/testsuite/
  • TLS
  • ws extensions, like deflate etc that chrome/ff use
    • Chrome has Sec-Websocket-Extensions: permessage-deflate; client_max_window_bits, x-webkit-deflate-frame
  • Sec-WebSocket-Protocol? don't know if anyone uses that, despite it's presence in the RFC

More Examples

  • Chat example
  • Cursor sharing example
  • Demo of 3d physics server for mmo game

About

Rust Web Socket Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages