---
id: "T:cAlgo.API.WebSocketClientState"
kind: "enum"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/WebSocket/WebSocketClientState/"
---

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

# WebSocketClientState (enum)

An enumeration of different Web socket client states.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public enum WebSocketClientState
```

## Examples

C#:

```csharp
var client = new WebSocketClient();
client.Connect(new Uri("wss://stream.example.com/quotes"));
if (client.State == WebSocketClientState.Open)
    client.Send("subscribe EURUSD");
else
    Print("WebSocket state: {0}", client.State);
```

Python:

```python
from System import Uri

client = WebSocketClient()
client.Connect(Uri("wss://stream.example.com/quotes"))
if client.State == WebSocketClientState.Open:
    client.Send("subscribe EURUSD")
else:
    api.Print(f"WebSocket state: {client.State}")
```

## Values

- `WebSocketClientState.None` — Reserved for future use.
- `WebSocketClientState.Connecting` — The connection is negotiating the handshake with the remote endpoint.
- `WebSocketClientState.Open` — The initial state after the HTTP handshake has been completed.
- `WebSocketClientState.CloseSent` — A close message was sent to the remote endpoint.
- `WebSocketClientState.CloseReceived` — A close message was received from the remote endpoint.
- `WebSocketClientState.Closed` — Indicates the WebSocket close handshake completed gracefully.
- `WebSocketClientState.Aborted` — Indicates that the WebSocket has been aborted.

