gitmyhub

websocat

Rust ★ 8.6k updated 5mo ago

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions

A command-line tool for connecting to WebSocket servers from the terminal, like netcat but for WebSockets. It can also bridge WebSocket connections to TCP ports, UNIX sockets, or the input and output of external programs.

RustWebSocketSOCKS5setup: easycomplexity 2/5

Websocat is a command-line tool for communicating over WebSocket connections. WebSockets are a protocol that keeps a persistent two-way connection open between a client and a server, commonly used for real-time features in web applications like live chat, notifications, or streaming data. Normally, WebSocket connections are managed by application code, but websocat lets you open and interact with them directly from a terminal, the way you might test plain network connections with tools like netcat or curl.

The tool can act as a client connecting to an existing WebSocket server, or as a simple server that accepts incoming connections. You type messages in the terminal and they get sent over the connection, and incoming messages print to the screen. This makes it useful for quickly testing whether a WebSocket endpoint is working, debugging live services, or scripting automated interactions.

Beyond basic send and receive, websocat can bridge different connection types together. For example, it can accept a plain TCP connection on one port, wrap it in a WebSocket, and forward it somewhere else, then unwrap it back to TCP at the other end. It can pipe a WebSocket connection into the standard input and output of an external program. It supports UNIX domain sockets, SOCKS5 proxies, and both unencrypted and encrypted connections. There is also a broadcast mode that relays messages from any connected client to all other connected clients.

The tool is written in Rust and pre-built binaries are available for Linux, Windows, macOS, and Android. It can also be installed through standard package managers including Homebrew on macOS, pkg on FreeBSD, and cargo (the Rust package manager) from source. The README notes that building from source with very recent or very old Rust compiler versions may cause compatibility issues depending on which release you are building.

Where it fits