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?
In order to communicate using the WebSocket protocol, you need to create a WebSocket object; this will automatically attempt to open the connection to the server. The URL to which to connect; this should be the URL to which the WebSocket server will respond.
The Web Socket Endpoint represents an object that can handle websocket conversations. Developers may extend this class in order to implement a programmatic websocket endpoint. The Endpoint class holds lifecycle methods that may be overridden to intercept websocket open, error and close events.
Pings and Pongs: The Heartbeat of WebSockets At any point after the handshake, either the client or the server can choose to send a ping to the other party.
To open a websocket connection, we need to create new WebSocket using the special protocol ws in the url: let socket = new WebSocket("ws://javascript.info"); There's also encrypted wss:// protocol. It's like HTTPS for websockets.
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
For completeness, I'd like to add my own CLI tool: websocat.
$ websocat wss://echo.websocket.org/
qwer
qwer
1234
1234
It does not do the "browser" part of the question, but should be a valid substitute for "curl" in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With