WebSocket reconnects killing audio in Cognigy AppFoundry integration

Hey folks, quick question on the best way to handle WebSocket lifecycle in a Genesys Cloud AppFoundry app connected to NICE Cognigy.

We’ve built a bot wrapper that maintains a persistent WebSocket connection to our backend. The connection itself is solid, but we’re seeing these random disconnects every 15-20 minutes. The kicker is that when the socket drops and reconnects, the audio stream in the active conversation gets all laggy and choppy for the next few seconds. It’s not a hard fail, just this annoying stutter.

I’m using the standard genesys-cloud-node-sdk for the initial handshake, but the bot logic runs on a separate Node process. Here’s the reconnect logic I’m currently using:

socket.on('close', () => {
 console.log('Connection lost, reconnecting...');
 setTimeout(() => {
 initializeWebSocket();
 }, 5000);
});

Is that timeout too long? Or is there a specific header or keep-alive setting I need to push to keep the audio pipeline warm during the reconnect? The logs show a clean 1000 close code, so it’s not a crash. Just wondering if anyone else has hit this with the Cognigy integration.