What’s the correct way to handle the heartbeat for the Streaming Analytics WebSocket in Node.js without losing state? We’re trying to pipe analytics events directly into a Kafka topic. The connection establishes fine, and data flows for about five minutes. Then it just stops. No error logs, no disconnect callback. The client seems to hang.
Here is the consumer setup. It looks standard enough. The on('message') handler stops firing after that initial burst. We’re using the standard WebSocket library. I’ve checked the Kafka producer, it’s healthy. The issue is definitely upstream. Is the Genesys Cloud WebSocket requiring a specific ping interval that I’m missing? The docs mention a heartbeat but don’t specify the payload format for the client side. We’re seeing this happen consistently across different queue IDs. It’s not a network timeout on our end, the TCP connection stays open. Just silent.
const WebSocket = require('ws');
const ws = new WebSocket('wss://api-us.genesyscloud.com/v2/analytics/streaming/events');
ws.on('open', () => {
console.log('Connected to analytics stream');
});
ws.on('message', (data) => {
const event = JSON.parse(data);
// push to kafka here
kafkaProducer.send({ topic: 'genesys-analytics', messages: [event] });
});
ws.on('close', () => {
console.log('Disconnected');
});
Any idea what triggers the silent drop? We’re running this in Berlin timezone, but that shouldn’t matter for the WebSocket handshake. The events stop exactly at the 300-second mark. Every single time.