Connecting to OBS

Turn your Cables.gl patch into an OBS controller without browser sandbox restrictions.

Because Cables patches often run within an <iframe> or under strict browser origin sandboxing, establishing direct local WebSocket connections to 127.0.0.1:4455 can trigger security blocks or CORS issues.

Enter Ops.Team.CablesStudio.Externals.ExternalObsConnection: an op that establishes a reliable, bidirectional link between your Cables patch and OBS Studio using a dedicated top-level popup bridge and the native browser BroadcastChannel API.

Here is a how it works and how to set it up in your own patches!


What is ExternalObsConnection Op?

ExternalObsConnection is a specialized op designed to connect Cables directly to OBS Studio via WebSocket v5.

Instead of fighting sandbox and mixed-content limitations inside the Cables canvas frame, the op launches a sleek external popup bridge. That popup lives as a top-level window, connects directly to OBS Studio over local WebSocket (ws://127.0.0.1:4455), and mirrors commands and broadcast events back and forth using the high-performance browser BroadcastChannel API.

Why Use It?


How the Pieces Fit Together

Here is a look at the data flow between Cables, your browser, and OBS Studio:


┌────────────────────────────────────────────────────────┐
│ Your Browser                                           │
│                                                        │
│ ┌────────────────────────┐                             │
│ │ Cables.gl Patch        │                             │
│ │ (Inside Iframe)        │                             │
│ │                        │                             │
│ │ ExternalObsConnection  │                             │
│ └───────────┬────────────┘                             │
│             │                                          │
│             │ BroadcastChannel                         │
│             │ ("obs-external-bridge")                  │
│             ▼                                          │
│ ┌────────────────────────┐             Local WebSocket │
│ │ Popup Bridge Window    │ ◄────────────────────────►  │
│ │ (Top-Level Context)    │ ws://127.0.0.1:4455         │
│ └────────────────────────┘                             │
└────────────────────────────────────────┼───────────────┘
│
▼
┌───────────────────┐
│ OBS Studio        │
│ (WebSocket v5)    │
│ - Scenes          │
│ - Audio Mixer     │
│ - Transitions     │
└───────────────────┘

Step-by-Step Setup Guide

Step 1: Enable the WebSocket Server in OBS Studio

Before touching Cables, ensure OBS Studio is ready to accept WebSocket connections:

  1. Open OBS Studio (v28 or newer, which includes WebSocket v5 natively).

  2. Go to Tools > WebSocket Server Settings.

  3. Check Enable WebSocket server.

  4. Check or configure the Server Port (default is 4455).

  5. (Optional but recommended) Enable authentication and enter a Server Password.

  6. Click Apply and OK.


Step 2: Add the Op to Your Cables Patch

  1. In the Cables editor, press Escape or double-click to open the Op selector.

  2. Search for and place:


Ops.Team.CablesStudio.Externals.ExternalObsConnection

  1. Set your connection parameters in the op inspector:

Step 3: Open the Popup Bridge

Click the Open Popup button in the op inspector (or trigger it with an op like Button or Once).

Tip on Popups: Browsers will typically block popups that open automatically on page load. Triggering Open Popup via a user interaction (like clicking a button in your patch) ensures your browser permits the popup window without warnings.

Once opened, the popup bridge window will open with a dark diagnostic interface. It connects to OBS and displays a glowing green Connected badge, confirming that Cables and OBS are linked.


Sending Commands to OBS

The Request Data input accepts clean JSON objects. Updating Request Data automatically sends the request, or you can trigger Send Request manually.

1. Canonical OBS Request

You can pass the standard OBS WebSocket v5 structure:


{

"requestType": "GetSceneList",

"requestData": {}

}

2. Convenient Flat Parameters

For quick setup, you can place parameters directly at the top level without nesting requestData:


{

"requestType": "SetCurrentProgramScene",

"sceneName": "Camera 1"

}

3. Direct Batch Requests

Want to execute multiple operations at once? Pass an array into Request Data:


[

{

"requestType": "SetCurrentProgramScene",

"requestData": { "sceneName": "Main Presentation" }

},

{

"requestType": "SetInputMute",

"requestData": { "inputName": "Microphone", "inputMuted": false }

}

]


Automatic Rate Limiting & Throttling

When binding Cables UI sliders, MIDI faders, or mouse coordinates to OBS properties (like volume or filter settings), you might produce dozens or hundreds of events every second. Firing individual network requests at high frequency can overwhelm the WebSocket connection.

ExternalObsConnection includes an intelligent batching system:


Reacting to Live OBS Events

Communication isn't just one-way! When you switch scenes or adjust volume in OBS, ExternalObsConnection captures those events in real time.

  1. Connect the On Event output trigger to your patch logic.

  2. Read Event Name (e.g., CurrentProgramSceneChanged, InputMuteStateChanged, or RecordStateChanged).

  3. Inspect Event Data to extract payloads such as the active scene name or volume levels.

  4. Use subscriptions in the op inspector (e.g., Sub Scenes, Sub Inputs, Sub Volume Meters) to toggle which event categories you want to receive.


Summary of Ports

| Port Name | Direction | Description |

| :--- | :--- | :--- |

| Host / URL | Input | IP or hostname of the OBS WebSocket server (default: 127.0.0.1). |

| Port | Input | Port number of the server (default: 4455). |

| Password | Input | WebSocket authentication password. |

| Open / Close Popup | Input | Buttons to open or dismiss the external bridge window. |

| Request Rate (Hz) | Input | Automated batching frequency (0 = immediate execution). |

| Request Data | Input | Payload object or array describing the OBS command. |

| Connected | Output | Boolean indicating if the bridge is currently connected to OBS. |

| On Response | Output | Triggered whenever a command returns its response. |

| Response Data | Output | The response payload returned by OBS. |

| On Event | Output | Triggered when OBS broadcasts an event. |

| Event Name | Output | Name of the emitted event (e.g., CurrentProgramSceneChanged). |

| Error | Output | String containing error messages if a connection or request fails. |


Wrapping Up

With ExternalObsConnection, Cables becomes an interactive command center for your stream. Whether you're building interactive stream overlays that react to scene changes, generative VJ visuals triggered by OBS hotkeys, or custom browser-based remote control surfaces, you can now link Cables and OBS Studio with ease.

Happy patching!