Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
Netcat, curl and socat for WebSockets.
$ websocat ws://ws.vi-server.org/mirror
123
123
ABC
ABC
$ docker run --rm -ti ghcr.io/vi/websocat:nightly wss://ws.vi-server.org/mirror
123
123
ABC
ABCA$ websocat -s 1234
Listening on ws://127.0.0.1:1234/
ABC
123
B$ websocat ws://127.0.0.1:1234/
ABC
123$ chromium --remote-debugging-port=9222&
$ curl -sg http://127.0.0.1:9222/json/new | grep webSocketDebuggerUrl | cut -d'"' -f4 | head -1
ws://127.0.0.1:9222/devtools/page/A331E56CCB8615EB4FCB720425A82259
$ echo 'Page.navigate {"url":"https://example.com"}' | websocat -n1 --jsonrpc --jsonrpc-omit-jsonrpc ws://127.0.0.1:9222/devtools/page/A331E56CCB8615EB4FCB720425A82259
{"id":2,"result":{"frameId":"A331E56CCB8615EB4FCB720425A82259","loaderId":"EF5AAD19F2F8BB27FAF55F94FFB27DF9"}}$ websocat --oneshot -b ws-l:127.0.0.1:1234 tcp:127.0.0.1:22&
$ websocat --oneshot -b tcp-l:127.0.0.1:1236 ws://127.0.0.1:1234/&
$ nc 127.0.0.1 1236
SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u3
qwertyu
Protocol mismatch.A$ websocat -t ws-l:127.0.0.1:1234 broadcast:mirror:
B$ websocat ws://127.0.0.1:1234
C$ websocat ws://127.0.0.1:1234(if you like this one, you may actually want https://github.com/vi/wsbroad/ instead)
See moreexamples.md for further examples.
There are multiple options for installing WebSocat. From easy to hard:
pkg install websocat
Homebrew: brew install websocat
MacPorts: sudo port install websocat
cargo install websocat. If something fails with a -sys crate, try with --no-default-features;target/release/websocat somewhere to the PATH.Pre-built binaries for Linux (usual and musl), Windows, OS X and Android are available on the releases page.
cargo build --release.target/, e.g. in target/release/websocat.| Websocat versions | Minimal Rust version | Maximal Rust version |
|---|---|---|
| 4.0.0-alpha1 | 1.84 | ? |
| 1.12+ | ? | ? |
| 1.9 - 1.11 | 1.46 | maybe 1.63 |
| 1.6 - 1.8 | 1.34 | maybe 1.63 |
| 1.3 - 1.5 | 1.31 | 1.47? |
| 1.2 | 1.28 | 1.47? |
| 1.0-1.1 | 1.23 | 1.47? |
| 1.2 | ? | ? |
Note that building with legacy Rust version (e.g. 1.46) may require manually copying Cargo.lock.legacy to Cargo.lock prior to the building.
Early non-async versions of Websocat should be buildable by even older rustc.
Note that old versions of Websocat may misbehave if built by Rust 1.48 or later due to https://github.com/rust-lang/rust/pull/71274/.
It may be not a good idea to build v1.x line of Websocat with Rust 1.64 due to [IP address representation refactor]. It may expose previously hidden undefined behaviour in legacy dependencies. (In practice, it seems to just work though - but a lot of time passed since I checked Websocat properly and in detail).
websocat's wss:// may fail on Android. As a workaround, download certificate bundle, for example, from https://curl.haxx.se/ca/cacert.pem and specify it explicitly:
SSL_CERT_FILE=cacert.pem /data/local/tmp/websocat wss://echo.websocket.orgOr just use --insecure option.
Basic usage examples are provided at the top of this README and in --help message. More tricks are described in moreexamples.md.
There is a list of all address types and overlays.
`websocat --help=long` output…mirror: specifier, making it a bit different from ws://echo.websocket.org. There are --binary-prefix, --text-prefix and --base64 options to handle mixture of binary and text.-E or -u options or in backpressure scenarios prone to socket leak.rlwrap tool for more convenient CLI.seamapi/node-websocatDoes not work on windows "GetSystemTimePreciseAsZFileTime could not be located"
关于events.mux在ws中的直接明文暴漏,导致rpcid和approvalid泄漏造成的安全问题
Support scoop
Drop the musl requirement in the README
Websocat1 features missing in Websocat4
websocat sometimes doesn't flush pending data, hangs
autoreconnect with --preamble
Proper Errorcode reporting
maybe add discussions? maybe stats like curl?
Windows Named Pipe Support