> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bringits.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Subscribe WebSocket Event

> Subscribe to a WebSocket instance in the browser window context to monitor real-time messages

The Subscribe WebSocket Event command (Command Type: 11) establishes a WebSocket subscription by overriding specific WebSocket events on an existing instance in the browser's `window` object.

## Command Type

**Command Type ID:** 11

## Parameters

| Parameter             | Type            | Description                                                                                       | Required |
| --------------------- | --------------- | ------------------------------------------------------------------------------------------------- | -------- |
| **instance**          | string          | Path to the WebSocket instance in the browser's `window` object                                   | Yes      |
| **name**              | string          | A unique identifier for this WebSocket listener                                                   | Yes      |
| **timeout**           | number          | Timeout in milliseconds                                                                           | Yes      |
| **initialMessage**    | string          | A message to send immediately after subscribing                                                   | No       |
| **methodsToOverride** | Array of string | WebSocket methods to override. Possible values: `"onmessage"`, `"onerror"`, `"onclose"`, `"send"` | No       |

## Usage Examples

### Subscribe to a Page's WebSocket

```json theme={null}
{
  "command": "subscribe-websocket-event",
  "params": {
    "instance": "app.liveSocket",
    "name": "oddsListener",
    "timeout": 60000
  }
}
```

### Subscribe and Override onMessage

```json theme={null}
{
  "command": "subscribe-websocket-event",
  "params": {
    "instance": "window.feedSocket",
    "name": "feedListener",
    "timeout": 30000,
    "methodsToOverride": ["onmessage"],
    "initialMessage": "{\"type\":\"subscribe\",\"channel\":\"live\"}"
  }
}
```

## Related Commands

* [Listen](/stream/commands/browser/listen) - Listen to DOM events
* [Observe Property](/stream/commands/browser/observe-property) - Monitor window property changes
* [WebSocket](/stream/commands/ws/websocket) - Direct WebSocket connection (no browser context)
