We’ve got a custom AppFoundry widget talking to a Cognigy bot. The WebSocket connection to /api/v2/analytics/events/realtime works fine for the first 30 seconds. Then it just dies. No error code, just a clean disconnect on the client side. The audio latency spikes right before it drops, like 200ms delay.
Here’s the connection setup in our React component:
const ws = new WebSocket(`wss://api.mypurecloud.com/api/v2/analytics/events/realtime?token=${authToken}`);
ws.onopen = () => console.log('Connected');
ws.onclose = () => console.log('Disconnected unexpectedly');
ws.onerror = (err) => console.error('WS Error:', err);
The server logs show the connection is closed by the client. We’re sending a heartbeat every 15 seconds as per docs, but it’s not sticking. Is there a timeout setting we’re missing in the widget manifest or the WebSocket init? The bot responses are fine, it’s just the real-time event stream that chokes. Checked the network tab, no CORS issues.