Session Model
The gateway tracks which session submitted each order to determine which orders should be cancelled when a connection is lost. Each session is completely independent:- One session per API Key per gateway host: A client may have at most one active session per API Key per gateway host
- Independent sessions: Two sessions for the same API key on different gateway hosts (Gateway A vs Gateway B) are completely independent with respect to CoD
- Session-to-order mapping: This enables accurate cancellation scoped to the disconnected session
Cancellation Behavior and Detection
When a connection is lost, CoD triggers instantaneously and cancels all active orders and quotes (from mass quote requests) submitted through the disconnected session. Cancelled orders are reported via theOrdersCanceled unsolicited event message, which includes:
- The cancelled orders (buy orders, sell orders, and quotes)
- The
cancelReasonfield indicating the reason for cancellation - Order details including
clientOrderId,orderId,instrumentId, andtotalFilled
- TCP connection closure
- Missing heartbeats — SBE uses heartbeats to detect connection issues, helping detect stale or dropped connections more quickly. Heartbeat monitoring cannot be disabled.
- Explicit logout
Authentication occurs only at logon time before any orders can be submitted, so it has no impact on cancellation detection.
Connection Management
Re-establishment
If a connection is lost and then re-established:- Orders are not automatically restored — clients must resubmit orders if they wish to maintain their order book
- CoD remains always enabled on the new session
Multiple Gateway Connections
When using multiple gateway connections, each session operates independently:- Orders submitted on Gateway A are only cancelled if the Gateway A session is lost
- Orders submitted on Gateway B are only cancelled if the Gateway B session is lost
- Losing one session does not affect orders on other sessions
Cross-Session Amends and CoD
CoD is bound to the session that originally submitted the order and does not rebind when the order is amended from a different session. If an order is submitted on session A with CoD enabled and later amended from session B, disconnecting session A will still cancel the order — even if session B remains connected. See Gateway Connectivity for more information on managing multiple connections.Best Practices
- Monitor Connection Health: Implement robust connection monitoring and automatic reconnection logic to minimize unintended CoD triggers
- Handle Cancellations: Ensure your application properly handles
OrdersCanceledmessages to maintain accurate order state - Re-submit Orders: After reconnecting, evaluate whether previously cancelled orders should be resubmitted based on current market conditions
- Session Independence: Remember that each session is independent — orders submitted on one session will only generate events on that session
- Graceful Logout: When intentionally disconnecting, use a proper logout sequence.
CoD cannot be disabled and will always trigger regardless of logout method.