---
id: "E:cAlgo.API.WebSocketClient.BinaryReceived"
kind: "event"
type: "T:cAlgo.API.WebSocketClient"
url: "https://help.ctrader.com/ctrader-algo/references/WebSocket/WebSocketClient/BinaryReceived/"
---

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

# WebSocketClient.BinaryReceived

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

## BinaryReceived

Occurs when WebSocketClient receives binary data.

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 event Action<WebSocketClientBinaryReceivedEventArgs> BinaryReceived;
```

Python:

```python
webSocketClient.BinaryReceived += handler  # handler(obj: WebSocketClientBinaryReceivedEventArgs)
```

### Returns

`Action<WebSocketClientBinaryReceivedEventArgs>` — 

### Examples

C#:

```csharp
private WebSocketClient _client;

protected override void OnStart()
{
    _client = new WebSocketClient();
    _client.BinaryReceived += OnBinaryReceived;
    _client.Connect(new Uri("wss://stream.example.com/quotes"));
}

private void OnBinaryReceived(WebSocketClientBinaryReceivedEventArgs args)
{
    Print("Received {0} bytes: {1}", args.Data.Length, Encoding.UTF8.GetString(args.Data));
}
```

Python:

```python
from System import Uri
from System.Text import Encoding

def on_start(self):
    self.client = WebSocketClient()
    self.client.BinaryReceived += self.on_binary_received
    self.client.Connect(Uri("wss://stream.example.com/quotes"))

def on_binary_received(self, args):
    api.Print(f"Received {args.Data.Length} bytes: {Encoding.UTF8.GetString(args.Data)}")
```

