vi / websocat

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

send a message and listen for incoming messages #207

Open GopherJ opened 10 months ago

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

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

ls84 commented 2 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 2 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.