Using the Genesys Cloud SDK to connect a Cognigy bot via WebSocket. The connection drops every 60 seconds and audio has a 2-second delay. We’re using this code: var ws = new WebSocket('wss://api.us.genesyscloud.com/v2/conversations/...');. Is there a specific header needed to keep the socket alive?
Hey, that 60-second drop is usually just the standard WebSocket idle timeout kicking in. The platform expects a ping/pong handshake to keep the session alive. If your client isn’t sending those control frames, the server closes the connection.
For the audio lag, WebSockets aren’t really built for low-latency media streams. You’ll want to look at the WebSocket API for bot integration specifically, rather than trying to stream raw audio over a generic WS connection. Make sure you’re using the correct endpoint for conversational AI, which handles the message framing for you.
Here is how you set up the client with the right headers and keep-alive logic in C#:
var client = new PureCloudPlatformClientV2.Client();
client.Configuration.AccessToken = "your_token";
// Ensure you are using the Conversations WebSocket API, not raw WS
var wsUrl = "wss://api.us.genesyscloud.com/v2/conversations/websocket";
You’ll need to handle the OnMessage event to send periodic pings. It’s a bit of extra work, but it stops the drops. Check the SDK docs for the WebSocketClient class implementation.