daydreamer daydreamer - 1 year ago 364
Javascript Question

How to hit the WebSocket Endpoint?

I see that there is websocket endpoint which works out fins with Java tests. In logs I see

Connecting to: ws://

Just like any other
API I would like to hit it via browser or curl, but when I do that I see

➜ tweetstream git:(master) ✗ curl ws://
curl: (1) Protocol ws not supported or disabled in libcurl


➜ tweetstream git:(master) ✗ curl
<html><head><title>Error</title></head><body>Not Found</body></html>%

Is there a way to test websocket APIs with browser/curl?

Answer Source

If you mean literally to test the implementation of websockets, I found Autobahn's test suite to be very useful:

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://");
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");