> For the complete documentation index, see [llms.txt](https://docs.ndi.video/all/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ndi.video/all/developing-with-ndi/utilities/bridge-service/websockets.md).

# WebSockets

Bridge Service supports WebSocket connections for listening to changes in any property. Logs are also sent over WebSocket connections. Data transmitted through the WebSocket connection is in JSON format. Active WebSocket connections can be viewed under the **WebSockets** section of the web interface. The WebSocket is listening on endpoint /stream

```
        using var client = new ClientWebSocket();
        
        // the websocket path is /stream
        // if you are using SSL you also need to use the wss protocol and
        // supply an API key in the x-api-key request header
        var endpoint = "ws://127.0.0.1:8080/stream";

        // var endpoint = "wss://127.0.0.1:8080/stream"; // for ssl
        // client.Options.SetRequestHeader("x-api-key", /* your key */); // for ssl

        await client.ConnectAsync(new Uri(endpoint), CancellationToken.None);
        Console.WriteLine("Connected to WebSocket server.");

        var buffer = new byte[4096];
        while (client.State == WebSocketState.Open)
        {
            var result = await client.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);

            if (result.MessageType == WebSocketMessageType.Text)
            {
                string message = Encoding.UTF8.GetString(buffer, 0, result.Count);
                Console.WriteLine(message);
            }
            else if (result.MessageType == WebSocketMessageType.Close)
            {
                await client.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closing", CancellationToken.None);
                Console.WriteLine("Connection closed.");
            }
        }
```

![Active WebSockets](/files/QIgrhcQRLITUZIHqy7Gq)

![Example WebSocket Output](/files/ptzWc4BXlk7ehFTW1EHU)

***

{% hint style="info" %}
Was this helpful? Please let us know by rating this page; you can also leave a [review](https://forms.office.com/Pages/ResponsePage.aspx?id=pzs8xttADka98eY6AqOtWZeUcJXxBylLhfBY94EFe29UNjZRV0xTOFdHR09INzRaN1BDVFFWT0lNRi4u).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ndi.video/all/developing-with-ndi/utilities/bridge-service/websockets.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
