Minimal WebSocket client.

Synopsis

websocat [FLAGS] [OPTIONS] <ws://URL | wss://URL>

Description

Sends stdin lines as WebSocket messages and prints received messages to stdout. Server mode and advanced specifiers (exec:, tcp:, broadcast:, ws-l:, etc.) are not supported; this websocat is client-only.

Options

-t, --text Send stdin as text messages (default).

-b, --binary Send stdin as binary messages.

-1, --one-message Send and/or receive exactly one message, then exit.

-n, --no-close Do not send a Close frame on stdin EOF.

-E, --exit-on-eof Exit once the peer closes its half.

-u, --unidirectional Only send (do not print received messages).

-U, --unidirectional-rev Only receive (do not send anything from stdin).

-q Suppress diagnostic messages; -v Verbose (repeat for more).

--base64 Encode binary messages as base64 on output.

--jsonrpc Wrap stdin lines as JSON-RPC 2.0 method calls.

--close-status-code N / --close-reason TEXT Customize the Close frame.

-B, --buffer-size N Max inbound message size in bytes (default 65536).

--max-messages N Exit after N inbound messages.

--protocol NAME WebSocket subprotocol (Sec-WebSocket-Protocol).

--conn-timeout SEC Abort connect after SEC seconds (default 30).

-H, --header "K: V" Accepted for parity; browsers reject arbitrary headers — only --protocol is honored.

Examples

$ echo hello | websocat -1 wss://ws.vi-server.org/mirror

Send one message and print the echoed reply.

$ S

e

Notes

Runs inside the browser, so it cannot open a WebSocket server or set arbitrary request headers (only --protocol is passed through); -k/--insecure is a no-op since certificate validation is fixed by the browser.

See Also

curl, curlwright