WebSocket
{
"jsonrpc": "2.0",
"id": 9098,
"method": "public/set_heartbeat",
"params": {
"interval": 30
}
}{
"jsonrpc": "2.0",
"id": 9098,
"result": "ok"
}
Session Management
public/set_heartbeat
Signals the WebSocket connection to send and request heartbeats. Heartbeats are used to detect stale or broken connections.
Heartbeat & Disconnect Lifecycle:
- When no message has been sent to the client for
intervalseconds, the server sends aheartbeatnotification ("params": {"type": "heartbeat"}). - When no message has been received from the client for
intervalseconds (plus 500 ms), the server sends aheartbeatnotification with"params": {"type": "test_request"}. Respond by sending a/api/v2/public/testrequest. - Any JSON text message from the client counts as activity and restarts this timer; WebSocket-level ping/pong frames and the plain-text
ping/PINGmessages do not. - If the connection stays silent until
(2 * interval) + 500 msafter the last client message, the server closes the WebSocket with close code 4000 (heartbeat close). - If Cancel on Disconnect is enabled for the connection (connection or account scope), orders created over this connection are cancelled when it is closed.
- Calling this method again replaces the previous interval.
Validation: interval must be an integer between 10 and 300 seconds inclusive. Any other value (including fractional numbers) returns JSON-RPC error -32602.
WebSocket Only: This method is designed exclusively for WebSocket connections. Calling it over REST/HTTP returns error 10030 (must_be_websocket_request).
WebSocket
{
"jsonrpc": "2.0",
"id": 9098,
"method": "public/set_heartbeat",
"params": {
"interval": 30
}
}{
"jsonrpc": "2.0",
"id": 9098,
"result": "ok"
}
Query Parameters
Was this page helpful?