#websocket-server #echo-server #twist #implemented #tokio

app twists

Example WebSocket Echo Server implemented with twist

14 releases

Uses old Rust 2015

0.2.1 Mar 21, 2017
0.2.0 Mar 19, 2017
0.1.12 Mar 6, 2017
0.1.6 Feb 25, 2017

#12 in #echo-server

Download history 4/week @ 2024-02-14 9/week @ 2024-02-21 52/week @ 2024-02-28

65 downloads per month

MIT/Apache

26KB
562 lines

twists

Example WebSocket echo server implemented with twist based on tokio

TODO

The base library twist does not yet implement all of RFC 6455. For example, protocols and exntension passed in the client header are ignored. This will come in time.

Install

Install twists with cargo

cargo install twists

Running

By default twists will listen for incoming connections at 127.0.0.1:11579

twists

You can test with the wscat utility

wscat ws://127.0.0.1:11579 -k 5

The above will send a ping frame every 5 seconds. You should see pongs back. Also text frames will be echoed back.

Help

Command line help

twists --help

Examples

Enable trace output

twist -vvv

Change the unsecure address and port

twist -a 10.0.0.0 -p 12345

TLS Support

twists has support for listen for TLS connections. To enable, you need a valid .pfx file. twists uses native-tls, and native-tls requires a valid pfx file with password. By default, twists will run on port 32276. This can be changed via the tlsport command line argument.

export PFX_PWD='the password for the pfx file'
twists -a 10.x.x.x --with-tls -f path/to/pfx

I use fish shell, so

set -lx PFX_PWD 'the password for the pfx file'
twists -a 10.x.x.x --with-tls -f path/to/pfx

Autobahn Test Suite Results

Results

Notes: The secure results reflect a connection out over the internet and back. This is due to the hostname requirements of TLS and the need for a valid (read: not self-signed) certificate.

Dependencies

~24–34MB
~618K SLoC