Node.js WebSocket consumer for Genesys Notification events dropping messages

Hey everyone,

I’m trying to set up a real-time stream for WFM adherence alerts. The goal is to subscribe to Notification API events (specifically routing.queue.member.events) and push them into a local Kafka topic using Node.js. I’ve got the OAuth token generation working fine, and I can manually trigger events in the sandbox that show up in the Genesys UI.

The issue is that my Node.js consumer connects to the WebSocket endpoint, receives the initial subscription confirmation, but then stops receiving data after about 30 seconds. No errors, just silence. I’m using the ws library.

Here’s the core setup:

const WebSocket = require('ws');
const { getAccessToken } = require('./auth');

async function startConsumer() {
 const token = await getAccessToken();
 const ws = new WebSocket('wss://api.mypurecloud.com/api/v2/notifications/stream');

 ws.on('open', () => {
 console.log('Connected to notification stream');
 // Subscribe to queue member events
 ws.send(JSON.stringify({
 action: 'subscribe',
 topic: 'routing.queue.member.events',
 subscription: {
 data: {
 queueId: 'my-test-queue-id'
 }
 }
 }));
 });

 ws.on('message', (data) => {
 const msg = JSON.parse(data);
 console.log('Received event:', msg.topic);
 // Push to Kafka here
 });

 ws.on('close', () => {
 console.log('WebSocket closed');
 });
}

The logs show “Connected to notification stream” and then nothing. I checked the server logs in Genesys and see no active subscriptions for this token after the initial handshake. Is there a keep-alive ping/pong requirement I’m missing? The docs mention it briefly but don’t give a code example for Node.js. I tried adding a simple setInterval to send a ping, but the connection still dies silently.

Also, when I look at the raw data in a browser-based WebSocket client, I see messages flowing every few seconds. Same token, same topic. So it’s not an auth or permission issue.

Any ideas on why the Node.js client drops off? I’m stumped.