Running into a persistent issue with our Genesys Cloud AppFoundry integration. We have a Node.js service that maintains a WebSocket connection to the Genesys Cloud platform API to receive interaction events. The service also bridges audio to a NICE Cognigy bot via WebRTC. Every 45 seconds, the WebSocket connection drops with a 1006 close code. The logs show the connection is established successfully, but then the server sends a close frame without a proper reason code. We’ve implemented a standard heartbeat mechanism as per the docs, sending a ping every 15 seconds. The client responds with a pong. This works fine for the first minute. After that, the connection just dies. The audio latency spikes right before the drop, suggesting the underlying transport is struggling. We’re using the @genesyscloud/api-client-sdk for authentication and token refresh, but the WebSocket itself is raw. We’ve tried increasing the buffer size and adjusting the keep-alive settings on the Node.js ws library. No luck. The Genesys Cloud docs mention a 60-second idle timeout, but we’re actively sending pings. Is there a specific header or message format required for the heartbeat that we’re missing? The payload we’re sending is just {"type": "ping"}. We’ve also tried sending an empty text frame. Same result. The error log from the Genesys Cloud side isn’t very helpful, just showing a generic disconnect. We need to keep this connection alive for the duration of the call, which can be up to 10 minutes. Any ideas on what might be causing the 1006 close? We’ve checked the network traces and don’t see any TCP resets from the load balancer. It seems like the Genesys Cloud server is initiating the close. We’re running this on AWS ECS with a Fargate task. The CPU and memory usage are well within limits. We’ve also verified that the OAuth token isn’t expiring during the connection. The token has a 24-hour expiry, so that’s not it. We’re using the /api/v2/analytics/events endpoint for the WebSocket connection. We’ve also tried the /api/v2/analytics/events/interactions endpoint. Same issue. We’re at a loss. Any help would be appreciated. Here’s the relevant code snippet for the WebSocket connection setup and heartbeat logic. We’re using the ws library in Node.js. The connection is established using the URL from the OAuth token response. We’re passing the token as a query parameter. We’ve also tried passing it in the Authorization header. Same result. We’re using the reconnect option in the ws library. This helps, but the reconnection delay causes a noticeable gap in the audio stream. We need a more stable connection. We’ve also tried using the socket.io library. Same issue. It seems to be specific to the Genesys Cloud WebSocket endpoint. We’ve checked the Genesys Cloud status page and there are no reported outages. We’ve also reached out to support, but they’ve suggested checking our code. We’ve spent the last two days debugging this. We’re running out of ideas. Here’s the code. Any insights would be great. We’re using Node.js 18. We’ve also tried upgrading to Node.js 20. Same issue. We’re using the latest version of the ws library. We’ve also tried downgrading to an older version. Same issue. We’ve checked the DNS resolution for the Genesys Cloud endpoints. Everything looks fine. We’ve also checked the TLS configuration. No issues there. We’re using TLS 1.3. We’ve also tried forcing TLS 1.2. Same result. We’re stumped. Any help would be appreciated.