WebSocket drops on Cognigy handoff via AppFoundry iframe

Working on a custom AppFoundry app that embeds a Cognigy bot inside the Genesys Cloud agent desktop. The goal is to keep the voice channel active while the bot handles the conversation logic. Using the standard WebSocket connection for the voice stream.

The connection stays stable for about 45 seconds. Then it drops with a 1006 error. No graceful close event from the server. The audio latency spikes right before the drop.

Here is the connection setup code:

const wsUrl = `wss://api-us-east-1.genesiscloud.com/api/v2/voice/connections/${connectionId}`;
const socket = new WebSocket(wsUrl, [headers]);

socket.onopen = () => {
 console.log('Connected');
};

socket.onclose = (event) => {
 console.log('Closed:', event.code, event.reason);
 // 1006 happens here
};

The connectionId comes from the /api/v2/voice/connections endpoint. I verified the token is valid and has voice:agent scope. The headers include the Authorization Bearer token and the X-Genesys-Application-Id.

I’ve tried increasing the keep-alive ping interval in the WebSocket client. Didn’t help. The drop happens regardless of whether the bot is responding or silent. If I use the standard Genesys softphone UI, no drops occur. It’s only when the call is associated with our AppFoundry iframe.

Is there a specific header required for the WebSocket upgrade request when coming from an embedded context? Or is this a known issue with the voice stream when the UI is not the primary focus?