WebSocket
Open a WebSocket connection, send messages by hand and watch everything the server sends back, in one tab.
What a WebSocket is
A normal HTTP request is one question and one answer. A WebSocket is a connection that stays open, so the client and the server can both send messages at any time. Chat apps, live prices and multiplayer games use it.
A WebSocket address starts with ws:// (plain) or wss:// (encrypted), the same way web addresses start with http:// or https://.
Make your first connection
This example uses wss://echo.websocket.org, a public test server that sends back every message it receives.
In the tab bar, select the small arrow next to + and choose WebSocket.
A tab named New WebSocket opens with
wss://in the URL field.Type
wss://echo.websocket.orgin the URL field.Select Connect, or press Enter in the URL field.
The status changes from Disconnected to Connecting… and then Connected. The log in the lower pane notes the connection, and this server sends one greeting line.
On the Message tab, type
helloin the Message box.Select Send.
The log lists your message as Sent and the server's copy as Received, each with its time and size.
Select Disconnect when you are done.
Good to know
Public test servers can change or go away. Any WebSocket server works the same way, including one running on your own computer, for example ws://localhost:8080.
Write messages
The Message tab is the composer. Pick the message type first:
| Type | What is sent |
|---|---|
| Text | The text exactly as typed. |
| JSON | The text, after a check that it is valid JSON. The log shows it indented. Format re-indents what is in the box. |
| Binary | The bytes of the base64 text you type, for example SGVsbG8=. |
Variables such as {{token}} are filled in when you send. Send is available only while the connection is open.
Saved messages
Keep messages you send often with the request:
Write the message in the Message box.
Select Save message and give it a name.
Under Saved messages, use the send icon to send it, the pencil to put it back in the box, or the cross to delete it. Select the name to rename it.
Params and headers
- Params are added to the end of the URL as its query string when you connect.
- Headers are sent with the upgrade request that opens the connection. Use them for a token, for example
Authorization: Bearer {{token}}.
Unticked rows are kept but not sent. An address that starts with http:// or https:// is connected as ws:// or wss://.
Connection settings
The Settings tab holds the options for this connection.
| Setting | What it does | Default |
|---|---|---|
| Subprotocols | Names offered in the Sec-WebSocket-Protocol header, separated by commas, for example graphql-ws. The server picks one, or none. | Empty |
| Ping interval (seconds) | How often a ping frame is sent to keep the connection alive. 0 sends no pings. | 0 |
| Reconnect automatically | When the connection drops or cannot be made, try again after a wait that doubles each time. Disconnect stops it. | Off |
| Attempts | Reconnect attempts in a row before giving up. 0 keeps trying. | 5 |
| First wait (ms) | The wait before the first reconnect attempt. | 1000 |
| Longest wait (ms) | The wait never grows beyond this. | 30000 |
A connection attempt that gets no answer within 20 seconds is given up.
Encrypted (wss://) connections follow the app's Verify TLS certificates setting, the proxy and the extra CA certificate. See App settings and Proxy and certificates.
Read the message log
The lower pane lists every message with its direction, time and size. System notes record connecting, disconnecting and errors.
| Control | What it does |
|---|---|
| Search messages | Shows only entries that contain your text. Case does not matter. |
| Filter | Chooses which entries to list: Sent, Received and System notes. |
| HEX / B64 | Shows binary messages as hex bytes or as base64. Copied binary messages use the same format. |
| Auto-scroll | Follows new messages. It pauses when you scroll up; select it to follow again. |
| Copy all | Copies every listed message as plain text, with time, direction and size. |
| Clear the log | Empties the log. The connection stays open. |
The log keeps the newest 2,000 entries and says how many older ones were dropped. A very long message is shortened on screen; copy the message to get all of it.
Save the connection
Select Save… above the URL to keep the tab in a collection. The URL, params, headers, settings, the draft message and your saved messages are stored with it. After that, Ctrl + S saves your changes.