Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
161
rated 0 times [  167] [ 6]  / answers: 1 / hits: 38737  / 10 Years ago, fri, july 11, 2014, 12:00:00

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



Connecting to: ws://127.0.0.1:8080/76f48a44-0af8-444c-ba97-3f1ed34afc91/tweets  


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



➜  tweetstream git:(master) ✗ curl ws://127.0.0.1:8080/b9b90525-4cd4-43de-b893-7ef107ad06c2/tweets  
curl: (1) Protocol ws not supported or disabled in libcurl


and



➜  tweetstream git:(master) ✗ curl http://127.0.0.1:8080/b9b90525-4cd4-43de-b893-7ef107ad06c2/tweets
<html><head><title>Error</title></head><body>Not Found</body></html>%


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


More From » curl

 Answers
17

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);

[#70228] Thursday, July 10, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cruzs

Total Points: 710
Total Questions: 113
Total Answers: 100

Location: Nepal
Member since Sat, Jul 18, 2020
4 Years ago
cruzs questions
Thu, Nov 26, 20, 00:00, 4 Years ago
Wed, Oct 28, 20, 00:00, 4 Years ago
Wed, Aug 19, 20, 00:00, 4 Years ago
Sun, Aug 2, 20, 00:00, 4 Years ago
;