Loading

CometD Subscribers May Lose Events and Receive Invalid ReplayId Due to Event Bus Backlog and Missing Replay Tightening

Fecha de publicación: May 6, 2026
Descripción

In rare cases, customers using the Streaming API (CometD) to subscribe to Change Data Capture (CDC) or Platform Events may experience a situation where zero events are delivered over extended periods — even though events exist within the 72-hour retention window — ultimately resulting in an invalid replayId error as events are purged from the Event Bus.

⚠️ This is a known limitation of the CometD / Streaming API protocol and does not affect the Pub/Sub API, which includes replay tightening semantics.

Symptoms

Customers may observe one or more of the following:

  • CometD client subscribes successfully but receives zero events for an extended period (hours)
  • Client is disconnected with 403: Unknown Client due to Streaming API session stickiness, this happens regardless.
  • Upon reconnect, the client resubscribes using the last known processed replayId but continues to receive zero events
  • After repeated cycles, the client eventually receives an invalid replayId error because events have aged out of the 72-hour retention window
  • The issue is more likely to occur with CDC events following a bulk publishing event (e.g., mass Bulk API data load) that generates millions of CDC events in a short window. The issue is also more likely to occur if there is a restrictive filter on the CDC channel.
Solución

Short-Term: Reduce Risk by Improving Client Reconnect Behavior

  • Ensure the client correctly handles all Streaming API Error Codes and reconnects within the 110-second socket timeout / 40-second reconnect timeout windows
  • Subscribe for longer sessions — ensure reconnect happens well within timeout windows to maximize seek progress per session
  • Terminate subscription after a period of not receiving events, establish new subscription with default Replay Option to receive new events (could lead to missed old events).
  • If CDC filters are involved, a short-term workaround is to relax the filter expression to come out of impact and continue the event delivery.

 

Long-Term: Migrate to Pub/Sub API

The recommended long-term solution is to migrate from CometD / Streaming API to the Pub/Sub API. The Pub/Sub API:

  • Supports replay tightening: when a subscriber reconnects, the replayId is automatically advanced past events from other orgs/channels that are not relevant to the subscriber, and the tightened replayId is returned to the client
  • Provides flow control via the num_requested parameter, which allows the client to control the rate of event delivery and avoid being overwhelmed by bursts. See: Flow Control in Pub/Sub API
  • Returns a 0-event response with a forwarded replayId when no events are available, allowing the client to distinguish between "no new events" and "still seeking through backlog"
Número del artículo de conocimiento

005321562

 
Cargando
Salesforce Help | Article