Skip to main content
Creating a WebSocket request in Bruno allows you to establish real-time connections and test bidirectional communication with WebSocket servers.

Creating a WebSocket Request

Step 1: Add New Request

  1. Open your collection in Bruno
  2. Right-click on the collection or folder where you want to add the request
  3. Select “New Request” from the context menu
  4. Choose “WebSocket” as the request type

Step 2: Configure WebSocket URL

  1. Enter the WebSocket URL in the address bar
    • Use ws:// for unsecured connections
    • Use wss:// for secured connections (recommended for production)
Example URLs:

Step 3: Configure Headers

  1. Click the Headers tab
  2. Add custom headers as needed:
    • Authorization: Bearer tokens, API keys
    • Custom Headers: Any additional metadata
    • User-Agent: Custom user agent strings
Common Headers:

Step 4: Set Connection Options

  1. Click the Settings tab
  2. Configure connection settings:
Connection Timeout
  • Set the maximum time to wait for connection establishment
  • Default: 30 seconds
  • Range: 1-300 seconds
Auto-reconnect
  • Enable automatic reconnection on connection loss
  • Useful for testing resilient WebSocket implementations

Step 5: Configure Subprotocols (Optional)

Bruno supports WebSocket subprotocols, allowing you to specify the application-level protocol to use over the WebSocket connection. Setting a Subprotocol WebSocket subprotocols enable your client to specify which protocol variant it wants to use. To set a subprotocol in Bruno:
  • Add the Sec-WebSocket-Protocol header in the Headers tab
  • Specify one or multiple subprotocols
Example:
Setting WebSocket Version You can specify the WebSocket protocol version using the Sec-WebSocket-Version header. This is useful when testing compatibility with servers that support multiple WebSocket versions:
WebSocket protocol version 13 (RFC 6455) is the current standard. Most modern servers use this version by default.
Server Rejections If the server doesn’t support the requested subprotocol or version:
  • The connection will be rejected
  • You’ll see a 400 Bad Request response
  • Check the response details to understand why the server rejected the connection
Advanced Header Overrides Bruno allows you to override other Sec-WebSocket-* headers if needed for testing specific scenarios:
  • Sec-WebSocket-Key: Custom key for handshake (auto-generated by default)
  • Sec-WebSocket-Extensions: Specify compression or other extensions
Simply add these headers in the Headers tab like any other custom header.