Skip to content

WebSocketClient.Close

method · WebSocketClient · cAlgo.API

DesktopCLICloud

Disconnects WebSocketClient.

Environment behaviour

Cloud — not supported. 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.

Definition

public void Close(WebSocketClientCloseStatus closeStatus, string closeStatusDescription)
webSocketClient.Close(closeStatus: WebSocketClientCloseStatus, closeStatusDescription: str) -> None

Parameters

Name C# type Python type Description
closeStatus WebSocketClientCloseStatus WebSocketClientCloseStatus Close status / reason.
closeStatusDescription string str Close status / reason description.

Examples

private WebSocketClient _client;

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

protected override void OnStop()
{
    _client.Close(WebSocketClientCloseStatus.NormalClosure, "cBot stopped");
}
from System import Uri

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

def on_stop(self):
    self.client.Close(WebSocketClientCloseStatus.NormalClosure, "cBot stopped")