Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read websocket response in linux shell

Writing a bash script to connect to GDAX's Websocket Feed at wss://ws-feed.gdax.com but curl doesn't seem to support this as I get

curl "wss://ws-feed.gdax.com" curl: (1) Protocol "wss" not supported or disabled in libcurl 
like image 750
J. Doe Avatar asked Dec 18 '17 00:12

J. Doe


People also ask

How do you read a WebSocket?

WebSocket uses a unified TCP connection and needs one party to terminate the connection. Until it happens, the connection remains active. HTTP needs to build a distinct connection for separate requests. Once the request is completed, the connection breaks automatically.

How do I open a WebSocket connection in Linux?

You can connect and exchange data with your server. By default each line becomes a WebSocket text message and vice versa. On Linux it is more comfortable to play with it using readline: rlwrap websocat ws://your_server/url.

How do I get data from a WebSocket?

The Message event takes place usually when the server sends some data. Messages sent by the server to the client can include plain text messages, binary data, or images. Whenever data is sent, the onmessage function is fired.


1 Answers

Assuming you have node installed, I would give wscat a shot; it is simple, intuitive, and powerful. Otherwise, @Pavel's answer has an abundance of venerable websocket client alternatives.

# install npm install -g wscat  # use wscat -c "wss://ws-feed.gdax.com" 
like image 58
Travis Clarke Avatar answered Sep 27 '22 21:09

Travis Clarke