WebSocket

Samvad has first-class WebSocket support for testing real-time bidirectional connections.


Creating a WebSocket Request

  1. In the sidebar, right-click a collection → New WebSocket
  2. Select WS from the method dropdown
  3. Enter your WebSocket URL: ws:// or wss://

Connecting

Click the Connect button (or the play icon) to establish the connection.

The connection status indicator shows:

  • 🔴 Disconnected — Not connected
  • 🟡 Connecting — Handshake in progress
  • 🟢 Connected — Active connection

Protocols

Samvad supports two WebSocket protocols:

Raw WebSocket

Send and receive arbitrary text or JSON messages directly. This works with any WebSocket server.

Sending a message:

  1. Type your message in the input field at the bottom
  2. Press Enter or click Send

Messages appear in the log with direction indicators:

  • Sent — your message
  • Received — server message
  • Closed — connection closed event

Example — Echo server:

// You send:
{ "action": "ping" }

// Server responds:
{ "action": "pong", "timestamp": 1720000000 }

GraphQL over WebSocket (graphql-ws)

Select graphql-ws protocol to interact with GraphQL subscriptions using the graphql-ws spec.

Subscribe to a GraphQL subscription:

subscription {
  messageAdded(channelId: "general") {
    id
    content
    sender
  }
}

Samvad handles the connection_init, subscribe, and complete messages automatically.

Multiple subscriptions — you can run multiple active subscriptions in one connection. Each subscription gets its own ID tracked internally.


Saved Messages

Frequently-used message templates can be saved and replayed:

  1. Type a message in the send field
  2. Click the Save (bookmark) icon
  3. Give it a name
  4. Access saved messages from the Saved tab

Message Log

The message log shows a real-time scrolling list of all communication:

Column Description
Direction ↑ Sent, ↓ Received, ✕ Closed
Data Message content
Timestamp ISO timestamp

Disconnecting

Click Disconnect to gracefully close the WebSocket connection. The log records the close event.


Tips

  • Use wss:// (TLS) in production — the app respects SSL verification settings.
  • Use graphql-ws mode for Hasura, Apollo Server, and other GraphQL WebSocket servers.
  • Saved messages are perfect for repeated test payloads (e.g., a fixed subscription query body).