TIL: Testing WebSocket Connections With wscat
If you’re building anything with WebSockets, you will spend a lot of time wondering if the connection works before you write the client code. wscat saves that step.
wscat -c wss://echo.websocket.org
Connected (press CTRL+C to quit)
> hello
< hello
> {"type":"ping"}
< {"type":"ping"}
It connects, sends, and receives. That is the whole thing. I used it constantly when testing Vonage’s WebSocket-based voice APIs. No import, no server, no HTML page. Just a URL and some messages.
How do you install wscat?
npm install -g wscat
Can it send binary data?
wscat handles text by default. For binary frames you need a client library, but for most API testing wscat covers what you need.