vi / websocat

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
MIT License
7.17k stars 278 forks source link

send a message and listen for incoming messages #207

Open GopherJ opened 1 year ago

GopherJ commented 1 year ago
echo '{"type": "subscribe", "address":"xxx"}' | RUST_LOG=error websocat ws://127.0.0.1:50051/ws
vi commented 1 year ago

websocat ws://127.0.0.1:50051/ws --preamble '{"type": "subscribe", "address":"xxx"}' ?

ls84 commented 4 months ago

What is the difference between the two? I am guessing use --preamble '{"type": "subscribe", "address":"xxx"}' will tell websocat to wait for connection is fully established? It will be great if this is explained. When I echo jsonrpc message it is always a Parse Error

vi commented 4 months ago

The main difference is that echo | websocat allows only one message and closes the connection after it (possibly after printing reply message) and --preamble specifies automatic initial message, then continues to read more messages from stdin.