Checking Websockets with cURL

August 7, 2019

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

$ 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" \
       http://example.com:80/

Just replace example.com 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.