I’m building a sidecar service in Node.js to consume Genesys Cloud analytics notifications via WebSocket and forward them to a local Kafka topic. The goal is to get real-time queue stats into our data lake without polling the REST API every second.
I’ve got the connection established using the ws library, and I’m subscribing to the analytics/queues event type. The initial handshake returns a 101 Switching Protocols, so auth is fine. The issue is reliability. About 30% of the events seem to vanish before they hit the Kafka producer.
Here’s the relevant snippet:
ws.on('message', (data) => {
const event = JSON.parse(data);
if (event.type === 'analytics/queues') {
producer.send({
topic: 'gen-analytics',
messages: [{ value: JSON.stringify(event) }]
}).catch(err => console.error('Kafka error:', err));
}
});
I’m not seeing any errors in the Kafka producer logs. The ws connection stays up, but the event count in Kafka is way lower than what I see in the Genesys UI. Is there a backpressure issue I need to handle in the WebSocket listener? Or am I missing a specific header in the subscription request to ensure all events are pushed? I’ve tried increasing the buffer size in the ws config but that didn’t help.