How to read websocket response in linux shell

后端 未结 5 1949
既然无缘
既然无缘 2020-12-24 07:18

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.gd         


        
5条回答
  •  旧时难觅i
    2020-12-24 07:53

    ws start connection by http protocol, you have to change ws to http and some extra headers like this:

    curl --include \
         --no-buffer \
         --header "Connection: Upgrade" \
         --header "Upgrade: websocket" \
         --header "Host: example.com:80" \
         --header "Origin: http://example.com:80" \
         --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
         --header "Sec-WebSocket-Version: 13" \
         "https://ws-feed.gdax.com"
    

    https://gist.github.com/htp/fbce19069187ec1cc486b594104f01d0

提交回复
热议问题