Dealing with a very strange bug here with the Genesys Cloud WebSocket analytics stream when piping events to a local Kafka topic via Node.js. The connection terminates unexpectedly with a 1006 code after approximately 5000 messages, despite the keepAlive interval being correctly configured.
It depends, but generally… the 1006 code usually indicates the server closed the connection without a proper close frame, which often happens when the client stops sending pings or fails to handle the pong event correctly in the ws library. I have seen this exact issue in ServiceNow integrations where the event loop gets blocked by heavy database writes, causing the WebSocket heartbeat to timeout. You need to ensure your ping/pong interval is shorter than the server’s idle timeout, typically 30 seconds. Here is a robust setup that handles backpressure and keeps the connection alive while writing to Kafka:
Verify that your keepAlive interval in the subscription payload matches your client-side ping interval to prevent the platform from dropping idle connections.