Send requests
WebSocket requests
How to connect to a WebSocket, send messages, read the message log, and what a WebSocket request cannot do.
A WebSocket request opens a live connection to a server. While it is open, you send messages and see what arrives, in the order it happens.
Example
Section titled “Example”echo.websocket.org is a public server that sends back every message it receives.
-
Create a WebSocket request, write the URL
wss://echo.websocket.organd press Connect. -
The server greets you with a line that starts with
Request served by. It appears in the log with ↓. -
Press Send (⌘/Ctrl + Enter) with the first message, Message 1, which a new request starts with:
{"type": "ping"}
The log shows your message with ↑, and the same message coming back with ↓.
Create a WebSocket request
Section titled “Create a WebSocket request”- In the sidebar, click New request under your collection.
- In the New request dialog, choose WebSocket.
- The request opens with the name New WebSocket. In the sidebar it has a WS badge.
Connect
Section titled “Connect”- Write the URL. It must start with
ws://orwss://, for examplewss://echo.websocket.org. - Press Connect. The status on the right changes to Connecting… and then to Connected, with the time the connection opened.
- To close the connection, press Disconnect.
Environment {{variables}} in the URL are replaced when you connect.
The connection stays open when you switch to another tab of Luvin. It closes when you press Disconnect, when the server closes it, or when you rename or delete the request.
Send messages
Section titled “Send messages”The left side keeps the messages you want to send. A new request starts with Message 1.
- Click a message in the list, or + New message to add one.
- Give it a name in the field above the editor, for example
Subscribe to prices. - Write the text. JSON is coloured as you type.
- Press Send (⌘/Ctrl + Enter).
Send works only while the status is Connected and the message has text. {{variables}} in the message are replaced when you send it.
Messages are saved with the request, so you can send them again later. To remove one, select it and click Delete next to its name.
For example, a message that subscribes to a channel:
{ "type": "subscribe", "channel": "prices", "symbol": "{{symbol}}"}The message log
Section titled “The message log”The right side shows everything that happened on the connection, newest first. Each line has a mark, the text and the time.
| Mark | Meaning |
|---|---|
| ↑ | A message you sent. |
| ↓ | A message that arrived. |
| • | A connection event: connecting, open or closed, with the close code. |
| ! | An error. |
- Click a message that is JSON to see it formatted. Click it again to fold it.
- Filter messages shows only the lines that contain the text you type.
- Clear empties the log.
The log keeps the latest 1,000 lines. It lives in memory: it is not saved with the request.
Limits
Section titled “Limits”- No custom headers. Browsers do not allow custom headers on a WebSocket, and Luvin connects the same way in the desktop app. Put what the server needs in the URL, for example
wss://api.example.com/stream?token={{token}}. - No Authorization tab. For the same reason, send the token in the URL or in the first message, as the server expects.
- No subprotocols. The connection is opened without one.
- Text messages. What you send is sent as text. A binary message that arrives is shown as text.
- A WebSocket request cannot be used as a workflow step.