---
id: "M:cAlgo.API.WebSocketClient.Connect(System.Uri)"
kind: "method"
type: "T:cAlgo.API.WebSocketClient"
url: "https://help.ctrader.com/ctrader-algo/references/WebSocket/WebSocketClient/Connect/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# WebSocketClient.Connect

Member of [WebSocketClient](https://help.ctrader.com/ctrader-algo/references/WebSocket/WebSocketClient/index.md).

## Connect(Uri uri)

Connects WebSocketClient to passed URI.

Environments: Desktop supported · CLI supported · Cloud not supported.

- Cloud: Connect, Send and Close do nothing: "WebSocket is not supported in cloud environment." is written to the log, State stays None and no events are raised.

C#:

```csharp
public void Connect(Uri uri)
```

Python:

```python
webSocketClient.Connect(uri: Uri) -> None
```

### Parameters

- `uri` (`Uri`, Python `Uri`): The server URI.

### Examples

C#:

```csharp
var client = new WebSocketClient();
client.Connected += args => Print("Connected to the quotes stream");
client.Connect(new Uri("wss://stream.example.com/quotes"));
```

Python:

```python
from System import Uri

client = WebSocketClient()
client.Connected += lambda args: api.Print("Connected to the quotes stream")
client.Connect(Uri("wss://stream.example.com/quotes"))
```

