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

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"

Well, you can try to mimic the required headers to get some response using curl:

  • https://gist.github.com/htp/fbce19069187ec1cc486b594104f01d0 or
  • Linux Bash: How to open a websocket connection as client

Also, there are other ways to communicate with a WebSocket server, e.g.

  • https://github.com/websockets/wscat
  • https://github.com/bwasti/webpipe
  • https://github.com/progrium/wssh