Skip to main content
The WebSocket V2 command (Command Type: 1) establishes a long-running WebSocket connection with event-driven command hooks. Supports native, SignalR, SignalR-legacy, and Socket.IO protocols.

Command Type

Command Type ID: 1

Parameters

ParameterTypeDescriptionRequired
urlstringWebSocket server URLYes
ciphersstringTLS cipher suites overrideNo
headersobjectCustom HTTP headers for the WebSocket handshakeNo
heartbeatIntervalMsnumberInterval in ms to re-publish the current result as a heartbeatNo
onCloseArray of CommandCommands to run when the connection closesNo
onConnectArray of CommandCommands to run once the connection is establishedNo
onErrorArray of CommandCommands to run when a socket error occursNo
onIntervalWebSocketV2OnIntervalCommands to run on a recurring interval while connectedNo
onMessageArray of CommandCommands to run for each incoming message (raw message placed in data)No
protocolstringProtocol variant: "native", "signalr", "signalr-legacy", "socketio"No
proxyProxySettingsProxy settings for the connectionNo
signalrWebSocketV2SignalRSettingsConfiguration for SignalR protocolNo
socketioWebSocketV2SocketIOSettingsConfiguration for Socket.IO protocolNo
stopOnWebSocketV2StopOnConditions that trigger an automatic connection stopNo

WebSocketV2OnInterval

FieldTypeDescriptionRequired
intervalMsnumberInterval between command executions in millisecondsYes
commandsArray of CommandCommands to execute on each tickYes

WebSocketV2SignalRSettings

FieldTypeDescriptionRequired
methodsArray of stringSignalR hub methods to subscribe toYes
skipNegotiationbooleanSkip the SignalR negotiation handshakeNo
transportstringTransport: "webSockets", "serverSentEvents", "longPolling"No

WebSocketV2SocketIOSettings

FieldTypeDescriptionRequired
eventsArray of stringSocket.IO events to subscribe toYes
pathstringSocket.IO server pathNo

WebSocketV2StopOn

FieldTypeDescription
inactivebooleanStop when the connection becomes inactive
itemDeletedbooleanStop when the associated item is deleted
serverClosebooleanStop when the server closes the connection

Usage Examples

Native WebSocket with onMessage Hook

{
  "command": "websocket-v2",
  "params": {
    "url": "wss://stream.example.com/feed",
    "onConnect": [
      { "id": 3, "type": "WS_V2", "params": { "sendMessage": "{\"type\":\"subscribe\"}" } }
    ],
    "onMessage": [
      { "id": 1002, "type": "PARSE", "params": { "path": "$.data" } }
    ],
    "stopOn": { "serverClose": true }
  }
}

SignalR Connection

{
  "command": "websocket-v2",
  "params": {
    "url": "https://hub.example.com/signalr",
    "protocol": "signalr",
    "signalr": {
      "methods": ["ReceiveOdds", "ReceiveEvent"]
    },
    "onMessage": [
      { "id": 6, "type": "WS_V2", "params": {} }
    ]
  }
}

With Heartbeat Interval

{
  "command": "websocket-v2",
  "params": {
    "url": "wss://stream.example.com/feed",
    "heartbeatIntervalMs": 5000,
    "onInterval": {
      "intervalMs": 30000,
      "commands": [
        { "id": 3, "type": "WS_V2", "params": { "sendMessage": "ping" } }
      ]
    }
  }
}