Checking websockets with cURL

August 7, 2019
terminal | http | curl | websockets

Here’s how to test a websocket connection using cURL:

$ curl --include \
       --no-buffer \
       --header "Connection: Upgrade" \
       --header "Upgrade: websocket" \
       --header "Host:" \
       --header "Origin:" \
       --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
       --header "Sec-WebSocket-Version: 13" \

Just replace with the hostname of your choice and you’ll see all the websocket data passing by…

Credits to this Gist on GitHub for the original snippet.