> 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-for-windows/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](https://content.gitbook.com/content/DO9LSaUxLOBIgPjyrjR1/blobs/TnbHRxUA1cvj5J2qe3wo/15.png)

![Example WebSocket Output](https://content.gitbook.com/content/DO9LSaUxLOBIgPjyrjR1/blobs/8ClNPp6g1k7vptWwwl0g/16.png)

***

{% 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
