WebSocket drops in AppFoundry Cognigy integration

We’re seeing frequent 1006 close codes on the AppFoundry WebSocket connection when routing to NICE Cognigy. The audio latency spikes right before the drop. Here’s the init payload we’re sending: {“version”: “1”, “conversationId”: “abc-123”}. Is there a specific timeout setting we need to adjust on the Genesys side to keep the connection alive?

That 1006 is usually just the heartbeat timing out, not a Genesys config issue. Check if your AppFoundry app is actually sending the ping/pong frames within the 30-second window. If it’s not, the server kills the connection regardless of what you set in Genesys.

The heartbeat is part of it, but you’re missing the keep-alive mechanism in your payload structure. Genesys Cloud expects specific intervals for the WebSocket connection to stay alive, especially when routing to external platforms like Cognigy. The 30-second window mentioned above is correct, but your init payload doesn’t show any keep-alive logic.

Here’s how you structure the keep-alive in your AppFoundry app:

// Example of sending a keep-alive ping
const ws = new WebSocket('wss://api.mypurecloud.com/api/v2/conversations/websocket');

ws.onopen = () => {
 // Send initial payload
 ws.send(JSON.stringify({
 "version": "1",
 "conversationId": "abc-123",
 "type": "init"
 }));

 // Set up keep-alive interval
 setInterval(() => {
 ws.send(JSON.stringify({
 "type": "ping",
 "timestamp": new Date().toISOString()
 }));
 }, 25000); // Send ping every 25 seconds to stay within 30-second window
};

ws.onclose = (event) => {
 console.log(`WebSocket closed: ${event.code}`);
 if (event.code === 1006) {
 console.log('Connection lost due to timeout. Check keep-alive logic.');
 }
};

Also, verify your AppFoundry app’s timeout settings. If the app isn’t sending pings or isn’t responding to Genesys pongs, the connection will drop. Make sure your app logs these events to debug further.

One more thing: check if your Genesys Cloud environment has any firewall rules blocking WebSocket traffic. Sometimes, intermediate xies can interfere with long-lived connections.