How To Hit The Websocket Endpoint?
Solution 1:
This did the trick for me:
$ curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: echo.websocket.org" -H "Origin: http://www.websocket.org" http://echo.websocket.org
from: http://www.thenerdary.net/post/24889968081/debugging-websockets-with-curl
Solution 2:
If you mean literally to test the implementation of websockets, I found Autobahn's test suite to be very useful: http://autobahn.ws/
If you just want to noodle with a websocket I would recommend using the developer tools in a browser like chrome to make a connection and send/recv data:
var ws = new WebSocket("ws://127.0.0.1:8080/76f48a44-0af8-444c-ba97-3f1ed34afc91/tweets");
ws.onclose = function() { // thing to do on close
};
ws.onerror = function() { // thing to do on error
};
ws.onmessage = function() { // thing to do on message
};
ws.onopen = function() { // thing to do on open
};
ws.send("Hello World");
Solution 3:
I had to use this command to make it work:
$ curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: echo.websocket.org" -H "Origin: http://www.websocket.org" -H "Sec-WebSocket-Version: 13" -H 'Sec-WebSocket-Key: +onQ3ZxjWlkNa0na6ydhNg==' http://www.websocket.org
I am using Jetty, and if I didn't add the Sec-WebSocket-Version/Sec-WebSocket-Key doesn't work. Just for the record.
Solution 4:
For completeness, I'd like to add my own CLI tool: websocat.
$ websocat wss://echo.websocket.org/
qwer
qwer
12341234
It does not do the "browser" part of the question, but should be a valid substitute for "curl" in this case.
Solution 5:
I have used this and found it to be quite simple
Post a Comment for "How To Hit The Websocket Endpoint?"