Skip to content

Instantly share code, notes, and snippets.

@higebu
Created May 12, 2016 11:32
Show Gist options
  • Save higebu/123794e0a0c3bc98e2fc535df2713cef to your computer and use it in GitHub Desktop.
Save higebu/123794e0a0c3bc98e2fc535df2713cef to your computer and use it in GitHub Desktop.
Test WebSocket with curl
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: echo.websocket.org" -H "Origin: https://www.websocket.org" https://echo.websocket.org
@higebu
Copy link
Author

higebu commented May 12, 2016

@dbolkensteyn
Copy link

This connects, but do you manage to get the echo service to actually work? On my side I am not seeing the data I enter on stdin being echo'ed:

curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: echo.websocket.org" -H "Origin: https://www.websocket.org" https://echo.websocket.org
HTTP/1.1 101 Web Socket Protocol Handshake
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type
Access-Control-Allow-Headers: authorization
Access-Control-Allow-Headers: x-websocket-extensions
Access-Control-Allow-Headers: x-websocket-version
Access-Control-Allow-Headers: x-websocket-protocol
Access-Control-Allow-Origin: https://www.websocket.org
Connection: Upgrade
Date: Wed, 15 Aug 2018 11:38:15 GMT
Server: Kaazing Gateway
Upgrade: WebSocket
WebSocket-Location: wss://echo.websocket.org/
WebSocket-Origin: https://www.websocket.org

test
lol

^D

^C

@dbolkensteyn
Copy link

wscat -c ws://echo.websocket.org however works as expected, see https://www.npmjs.com/package/wscat

It would be nice to achieve the same with just curl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment