Recently, I was searching for the
curl of WebSockets.
There are some GUI tools for playing with WebSocket connections, but I prefer the command line.
Turns out, there exists a command line tool that not only implements the client but can also act as a server.
Install it via
npm install -g wscat
and you're fine.
Now you can connect away:
$ wscat -c ws://echo.websocket.org -p 13
You can even run a WebSocket server:
$ wscat -l 8080 -p 13
To sum it up, you can run your local WebSocket session like this:
$ wscat -l 8080 -p 13 $ wscat -c ws://localhost:8080 -p 13
Note: Protocol Version 13 is the default for the server.
Package documentation is available.
Thanks to our friend Sebastian Cohnen for recommending to mention the server feature and explicitly including the protocol version (13).