We’re seeing intermittent connection drops when bridging Genesys Cloud voice calls to a Cognigy bot via AppFoundry. The WebSocket handshake succeeds, but the connection terminates exactly 30 seconds later if there is no audio payload sent from the bot side.
Here is the relevant from our Node.js AppFoundry application handling the gen-voice channel:
const ws = new WebSocket('wss://api.mypurecloud.com/api/v2/analytics/events');
ws.on('open', () => {
console.log('Connected to Genesys Cloud WebSocket');
// Send initial auth token
ws.send(JSON.stringify({
type: 'auth',
token: process.env.GENESYS_TOKEN
}));
});
ws.on('message', (data) => {
const msg = JSON.parse(data);
if (msg.type === 'audio') {
// Forward to Cognigy
cognigyClient.sendAudio(msg.payload);
}
});
ws.on('close', (code, reason) => {
console.log(`WebSocket closed: ${code} - ${reason}`);
// Reconnection logic here
});
The logs show:
WebSocket closed: 1006 - Abnormal Closure
We’ve tried sending a keep-alive ping every 10 seconds, but it doesn’t seem to prevent the drop. The audio latency spikes before the disconnect, suggesting the buffer is filling up or the stream is choking.
Has anyone implemented a stable long-running WebSocket bridge for voice? Is there a specific header or message type required to maintain the session? The docs are sparse on the keep-alive mechanics for the analytics/events endpoint in this context.