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

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

# WebSocketClientCloseStatus (enum)

An enumeration of different Web socket client close states / reasons.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public enum WebSocketClientCloseStatus
```

## Examples

C#:

```csharp
var client = new WebSocketClient();
client.Disconnected += args => Print("Closed with status {0}: {1}", args.Client.CloseStatus, args.Client.CloseStatusDescription);
client.Connect(new Uri("wss://stream.example.com/quotes"));
client.Close(WebSocketClientCloseStatus.NormalClosure, "cBot finished");
```

Python:

```python
from System import Uri

client = WebSocketClient()
client.Disconnected += lambda args: api.Print(f"Closed with status {args.Client.CloseStatus}: {args.Client.CloseStatusDescription}")
client.Connect(Uri("wss://stream.example.com/quotes"))
client.Close(WebSocketClientCloseStatus.NormalClosure, "cBot finished")
```

## Values

- `WebSocketClientCloseStatus.Empty` — No error specified.
- `WebSocketClientCloseStatus.EndpointUnavailable` — (1001) Indicates an endpoint is being removed. Either the server or client will become unavailable.
- `WebSocketClientCloseStatus.InternalServerError` — (1011) The connection will be closed by the server because of an error on the server.
- `WebSocketClientCloseStatus.InvalidMessageType` — (1003) The client or server is terminating the connection because it cannot accept the data type it received.
- `WebSocketClientCloseStatus.InvalidPayloadData` — (1007) The client or server is terminating the connection because it has received data inconsistent with the message type.
- `WebSocketClientCloseStatus.MandatoryExtension` — (1010) The client is terminating the connection because it expected the server to negotiate an extension.
- `WebSocketClientCloseStatus.MessageTooBig` — (1009) The client or server is terminating the connection because it has received a message that is too big for it to process.
- `WebSocketClientCloseStatus.NormalClosure` — (1000) The connection has closed after the request was fulfilled.
- `WebSocketClientCloseStatus.PolicyViolation` — (1008) The connection will be closed because an endpoint has received a message that violates its policy.
- `WebSocketClientCloseStatus.ProtocolError` — (1008) The client or server is terminating the connection because of a protocol error.

