Node SDK: Notification stream dropping analytics events on high volume

Running a Node consumer to pipe Genesys Cloud Notification events into Kafka. The WebSocket connection stays open, but I’m seeing significant gaps in the analytics data stream when call volume spikes. The SDK’s internal retry logic seems to handle disconnects, but I suspect the backpressure isn’t being managed correctly on the consumer side, causing events to queue up and drop before hitting my write callback.

Here’s the loop I’m using to process the stream:

const stream = apiInstance.notificationsApi.getStreamNotifications(
 'analytics',
 {
 filter: 'event.type eq "conversation:analytics"',
 subscriptionType: 'stream'
 }
);

stream.on('data', (event: any) => {
 kafkaProducer.send({
 topic: 'gc-analytics-stream',
 messages: [{ value: JSON.stringify(event) }]
 });
});

The kafkaProducer is async, but I’m not awaiting the send call to keep the stream moving. Is there a better pattern to handle backpressure here without blocking the WebSocket read? Or should I be using the batch endpoint instead?

You’re fighting the WebSocket buffer. Drop the real-time stream for analytics and switch to the REST API polling /api/v2/analytics/conversations/details/query with a 5-minute window. It’s slower but actually reliable for high volume.