# WebSocket Feature

As of UDiTH 2026.2.0, the API supports WebSocket connections between UDiTH App and AppControl Apps. This allows an AppControl App to run in a separate browser window, independent of the UDiTH App.

![WebSocket Overview](media/WebSocket_overview.png)

## Connection Establishment

The general workflow for establishing a connection is as follows:

1. Open the UDiTH App (running locally, not BBV).
2. Open an AppControl web page.
3. On the first attempt, the browser will ask whether the connection should be allowed:

   ![Browser Permission Prompt](media/WebSocket_browser_permission.png)

   The answer is stored in the local browser.

4. The UDiTH App will ask whether the WebSocket connection should be established:

   ![UDiTH Connection Prompt](media/WebSocket_udith_prompt.png)

## Handling Multiple Instances

The AppControl API connects to the first locally running UDiTH App (first in terms of startup time). If additional AppControl Apps are opened, they also connect to the same first UDiTH App. Locally running UDiTH Apps beyond the first one are ignored.

![Multiple Instances](media/WebSocket_multiple_instances.png)
## Troubleshooting

The connection can be refused from two sides: in the UDiTH App and in the browser. These refusals are the typical causes for unsuccessful WebSocket connections.

### Revoking Connection Refusals in UDiTH App

At the bottom of the **Expert Settings**, use the **Clear dis/approved AppControl urls** button to reset all previously approved or denied AppControl URLs.

![Clear AppControl URLs](media/WebSocket_clear_appcontrol_urls.png)

### Revoking Connection Refusals in the Browser

Click on the lock icon next to the URL bar:

![Browser Lock Icon](media/WebSocket_browser_lock_icon.png)

Then set **Apps on device** to **Allow** or **Ask**:

![Browser Apps Permission](media/WebSocket_browser_apps_permission.png)

### Disabeling WebSocket API in an App

Add this code snippet before calling the first API
```typescript
import { Api } from "@caxperts/universal.api/Internal/APIConnector";
Api.disableWebsocketApi = true;
```

Further Information and samples using AppControls and the Universal.API can be found via https://github.com/caxperts/AppControls