Overview
Sequence Numbers
So you can easily ensure that you are receiving all of your WebSocket messages in the expected order without any gaps, events and heartbeats contain a special sequence number.
- WebSocket connection is established
- Optional: subscription acknowledgement, such as Order Events: Subscription Acknowledgement
- Your subscription begins - you receive your first event with
socket_sequence
set to a value of0
- For all further messages, each message - whether a heartbeat or an event - should increase this sequence number by one.
- If you see a gap in this sequence number, then you should disconnect and reconnect.
Note:
- Each time you reconnect, the sequence number resets to zero.
- If you have multiple WebSocket connections, each will have a separate sequence number beginning with zero - make sure to keep track of each sequence number separately!