websocat

Command-line WebSocket client and server, like netcat, curl and socat for ws:// and wss://, with TCP/UNIX socket proxying and program execution.

install

websocat is a command-line client and server for WebSockets, comparable to netcat, curl and socat but for ws:// and wss:// endpoints. It has a simple client mode (websocat ws://URL), a simple server mode (websocat -s port), and an advanced mode that takes two address arguments (websocat [FLAGS] [OPTIONS] <addr1> <addr2>) in the style of socat, so any two endpoints can be connected.

Beyond plain connections, it can run an external program and connect its stdin/stdout to a WebSocket, proxy TCP connections to WebSockets and back (e.g. ws-l:127.0.0.1:1234 tcp:127.0.0.1:22), and broadcast messages between connected clients using broadcast:mirror:. It supports text and binary modes, conversion between lines (or null-terminated records) and messages, inetd mode, UNIX sockets including Linux abstract sockets, unauthenticated SOCKS5 servers, auto-reconnect and connection-reuse modes, and Nginx integration over TCP or UNIX sockets. Other options include --jsonrpc to format typed lines as JSON-RPC 2.0 calls (used in the README to drive Chromium's remote debugging port), deflate/gzip/zlib compression of binary messages, and --print-ping-rtts to print round-trip times.

Transports can be overridden, for example by calling an external program to handle SSL or proxying. Pre-built executables exist for Linux (glibc and musl), Windows, macOS and Android, and a container image is available at ghcr.io/vi/websocat. It suits developers testing or debugging WebSocket APIs, scripting against WebSocket services from the shell, and people bridging WebSocket traffic to ordinary TCP or stdio tools.

Installation

# via Homebrew
brew install websocat
# via FreeBSD pkg
pkg install websocat
# via Cargo
cargo install websocat

Alternatives & related tools

add a badge to your README

Maintain websocat? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/websocat.svg)](https://www.trmn.sh/tools/websocat?utm_source=badge)
HTML
<a href="https://www.trmn.sh/tools/websocat?utm_source=badge"><img src="https://www.trmn.sh/badge/websocat.svg" alt="Featured on trmn" height="20"></a>