Skip to main content

WebSocket

WebSocket provides full-duplex communication channels over a single TCP connection, ideal for real-time applications.

Overview

Connecting to a WebSocket

  1. Select WebSocket from the protocol dropdown
  2. Enter the WebSocket URL: wss://echo.websocket.org or ws://localhost:8080
  3. Click Connect

The connection status indicator will turn green when connected.

URL Schemes

SchemeDescription
ws://Unencrypted WebSocket
wss://Encrypted WebSocket (TLS)

Custom Headers

Add authentication or custom headers before connecting:

HeaderValue
AuthorizationBearer {{TOKEN}}
X-Custom-Headercustom-value
note

Headers are sent during the initial HTTP upgrade request and cannot be changed after connection.

Sending Messages

Once connected:

  1. Type your message in the input field
  2. Select message type: Text or Binary
  3. Click Send

Message Types

TypeDescription
TextUTF-8 encoded string (JSON, plain text)
BinaryRaw binary data

Message Log

The message log shows all communication:

DirectionDescription
↑ SentMessages you sent (blue)
↓ ReceivedMessages from server (green)
SystemConnection events (gray)

Each message shows:

  • Timestamp
  • Direction indicator
  • Message content

Actions

ActionDescription
ConnectEstablish WebSocket connection
DisconnectClose the connection
ClearClear the message log

Example: Echo Server

Using the playground WebSocket echo server:

URL: ws://localhost:19510/ws/echo
  1. Connect to the server
  2. Send a message: Hello, WebSocket!
  3. Receive echoed response:
{
"type": "echo",
"original": "Hello, WebSocket!",
"timestamp": "2024-01-15T10:30:00Z"
}

Example: Chat Application

URL: wss://chat.example.com/ws
Headers:
Authorization: Bearer {{AUTH_TOKEN}}
X-User-Id: {{USER_ID}}

Send JSON messages:

{
"type": "message",
"room": "general",
"content": "Hello everyone!"
}

Connection States

StateDescription
DisconnectedNo active connection
ConnectingHandshake in progress
ConnectedReady to send/receive
ClosingConnection closing

Troubleshooting

Connection Failed

  • Verify the URL is correct
  • Check if the server is running
  • Ensure ws:// vs wss:// matches server configuration

Messages Not Received

  • Check if the server expects a specific message format
  • Verify authentication headers are correct
  • Look for error messages in the log