Interaction events dropping after WebSocket reconnect - Predictive Routing

Hey all,

Seeing some seq ID gaps on the Predictive Routing event stream again - specifically interaction_routed events. It’s not a complete drop, but roughly 5-7% are missing after a reconnect. We’re on the latest 2.3 API version.

The connection is stable, heartbeat is every 2 seconds. Small thing, but it messes with our real-time queue monitoring. Last sequence ID received before disconnect is always followed by a larger number after reconnect, meaning something’s getting skipped. It’s not an ordering issue within a single connection, only across reconnects. Worth a shot to check the eventBridge logs, I guess?

  • The observed sequence ID gaps following WebSocket reconnection merit a systematic investigation of the underlying event stream handling logic. Specifically, it is CRITICAL to ascertain whether the client-side application is correctly implementing idempotent event processing - that is, whether duplicate events are gracefully handled.

  • Consider the implications of TCP’s unreliable delivery model, as described in RFC 793. Lost packets, although mitigated by TCP’s retransmission mechanisms, can still induce transient gaps in the sequence ID stream. We’ve observed similar behavior when relying solely on the sequence ID as an absolute ordering metric.

  • Given the reported heartbeat interval of two seconds, examine the WebSocket configuration parameters. Specifically, verify the maxFrameSize setting. Exceeding this limit will result in event fragmentation and potential ordering anomalies.

  • A secondary area for investigation concerns the predictive routing algorithm’s internal state. The algorithm might be relying on incomplete data post-reconnect, thereby leading to discrepancies in event processing. The documentation suggests maintaining a persistent event cache to mitigate this risk.

  • Finally, while the 2.3 API version is current, evaluate the possibility of introducing a client-side buffer. This buffer would temporarily store events until a stable connection is re-established, thereby ensuring sequence ID integrity.

1 Like