Skip to content

WebSockets

Orb supports WebSocket connections with both interactive and script-friendly modes.

Connect using ws:// (unencrypted) or wss:// (TLS) URLs:

Terminal window
# Secure WebSocket
orb wss://echo.websocket.org
# Unencrypted WebSocket
orb ws://localhost:8080/ws

Use --ws-message to send a message and exit:

Terminal window
orb wss://echo.websocket.org --ws-message "Hello, WebSocket!"

This:

  1. Connects to the WebSocket server
  2. Sends the message
  3. Receives the response
  4. Disconnects

Without --ws-message, orb enters interactive mode (when TTY is available):

Terminal window
orb wss://echo.websocket.org

In interactive mode:

  • Type a message and press Enter to send
  • Received messages are printed to stdout
  • Use Ctrl+C or Ctrl+D to disconnect

Use -v to see connection details:

Terminal window
orb -v wss://echo.websocket.org --ws-message "test"

Output:

* Connecting to wss://echo.websocket.org:443
* WebSocket connected to echo.websocket.org:443 (234ms)
> Text message (5 bytes)
< Text message (5 bytes)
* WebSocket closed: 1000 Normal Closure
OptionDescription
-H, --headerCustom headers for handshake
-A, --user-agentCustom User-Agent
--cert, --keyClient certificate (mTLS)
--cacertCA certificate
-k, --insecureSkip certificate verification
--connect-toDNS override
--connect-timeoutConnection timeout
-m, --max-timeMaximum total time
-v, --verboseVerbose output
-s, --silentSuppress output
Terminal window
orb wss://api.example.com/ws \
-H "Authorization: Bearer token123" \
-H "X-Custom-Header: value" \
--ws-message '{"type": "subscribe", "channel": "updates"}'
Terminal window
orb wss://secure.example.com/ws \
--cert client.pem \
--key client-key.pem \
--ws-message "Hello"

When stdin is not a TTY (e.g., in a script), orb waits for messages without prompting:

Terminal window
# In a script - just receives messages
echo "Hello" | orb wss://echo.websocket.org
# With timeout
orb -m 5 wss://stream.example.com # Disconnect after 5 seconds
Terminal window
orb wss://echo.websocket.org --ws-message "Hello, World!"

Expected output:

Hello, World!
Terminal window
# Receive real-time updates for 10 seconds
orb -m 10 wss://stream.example.com/prices
Terminal window
orb wss://api.example.com/ws \
--bearer "your-token" \
--ws-message '{"action": "subscribe", "topic": "updates"}'
Terminal window
# Interactive chat
orb wss://chat.example.com/room/general

Type messages and press Enter:

Hello everyone!
< {"user": "bob", "message": "Hi there!"}
< {"user": "alice", "message": "Welcome!"}
Thanks!
< {"user": "bob", "message": "How are you?"}
^C
* WebSocket closed: 1000 Normal Closure

These options don’t apply to WebSocket connections:

  • -X, --request - WebSocket uses GET for handshake
  • -d, --data, --json, -F - Use --ws-message instead
  • -o, --output - No file output for WebSocket
  • -i, --include, -I, --head - No HTTP response headers
  • -L, --location - No redirect following
  • --compressed - No HTTP compression
  • --http1.1, --http2, --http3 - Not applicable
  • -w, --write-out - No stats for WebSocket