| Crates.io | yawcc |
| lib.rs | yawcc |
| version | 0.1.3 |
| created_at | 2025-01-31 10:14:15.954106+00 |
| updated_at | 2025-06-10 12:05:13.325252+00 |
| description | CLI tool using yawc |
| homepage | |
| repository | https://github.com/infinitefield/yawc |
| max_upload_size | |
| id | 1537348 |
| size | 72,699 |
A command-line interface tool for WebSocket communication that supports both secure (wss://) and non-secure (ws://) connections with both client and server capabilities.
cargo install yawcc
yawcc c wss://fstream.binance.com/ws/btcusdt@aggTrade
yawcc c --input-as-json wss://fstream.binance.com/ws/btcusdt@aggTrade
yawcc c https://echo.websocket.org --tcp-host 127.0.0.1:8080
yawcc s
This starts a WebSocket server on localhost:9090 that echoes back any messages it receives.
yawcc s --listen 0.0.0.0:8080 --path /ws
This starts a WebSocket server on all interfaces (0.0.0.0) on port 8080 with the endpoint path /ws.
Usage: yawcc client [OPTIONS] <URL>
Arguments:
<URL> The WebSocket URL to connect to (ws:// or wss://)
Options:
-t, --timeout <TIMEOUT> Maximum duration to wait when establishing the connection. Accepts human-readable formats like "5s", "1m", "500ms" [default: 5s]
--include-time Includes the timestamp for each message
-H, --header <Headers> Custom headers to send to the server in "Key: Value" format For example: --header "Authorization: Bearer token123"
--input-as-json When enabled, validates and pretty-prints received messages as JSON. Invalid JSON messages will result in an error
--tcp-host <TCP_HOST> Connect directly to a TCP host instead of using WebSocket URL. Format: host:port (e.g., "127.0.0.1:8080")
-h, --help Print help (see more with '--help')
Usage: yawcc server [OPTIONS]
Options:
-l, --listen <LISTEN> Network address and port to listen on [default: 127.0.0.1:9090]
-p, --path <PATH> URI path to serve the WebSocket endpoint [default: /]
-h, --help Print help (see more with '--help')
Once connected, you can:
Example with comments:
> {"type": "ping"} // Heartbeat message
> {"command": "subscribe", "channel": "updates"} // Subscribe to updates
The built-in WebSocket server:
Example of connecting to the server with the client:
# In terminal 1, start the server
yawcc s --listen 127.0.0.1:9090 --path /ws
# In terminal 2, connect with the client
yawcc c ws://127.0.0.1:9090/ws
# Now you can send messages that will be echoed back
Command history is automatically saved to ~/.yawcc_history and is loaded when the client starts.
git clone https://github.com/infinitefield/yawc
cd yawc/yawcc
cargo build --release
Contributions are welcome! Please feel free to submit a Pull Request.