Node.js consumer dropping Analytics WebSocket events before Kafka commit

Hey everyone, I’m hitting a weird bottleneck with my Node.js worker that’s supposed to pipe Genesys Cloud Analytics notification events into a Kafka topic. The setup is pretty standard: I’m using the @genesyscloud/purecloud-platform-client-node-server SDK to grab the OAuth token, then establishing a WebSocket connection to the /api/v2/analytics/events endpoint. The goal is to stream real-time interaction data to our data lake.

The issue isn’t connecting. The handshake works fine, and I get the initial connectionId. But about thirty minutes into the run, the stream just… stalls. No errors, no close event, just silence. When I restart the worker, it floods the Kafka topic with a backlog of events it clearly received but didn’t process. My consumer logic is straightforward:

socket.on('message', (data) => {
 const events = JSON.parse(data);
 events.forEach(event => {
 producer.send({
 topic: 'genesys-analytics-stream',
 messages: [{ value: JSON.stringify(event) }]
 }).catch(console.error);
 });
});

I’ve added a timeout on the WebSocket client, but the keepalive mechanism seems to be fighting me. I’m running this in an AWS ECS task in ap-northeast-1 (Tokyo), and the latency to the Genesys API is usually under 50ms, so network lag shouldn’t be the culprit.

Is there a specific header or query param I need to tweak for long-running Analytics streams? I noticed the docs mention a maxWaitTime parameter for batch polling, but I thought that applied to the REST API, not the WebSocket push. Also, should I be handling the heartbeat frames differently? Right now I’m just letting them pass through, but maybe I need to send a pong back to keep the connection alive?

Any ideas on why the event flow stops without a clean disconnect? I can’t find much on this in the SDK issues either.