Running into a persistent issue with WebSocket stability in our Genesys Cloud AppFoundry bot built with NICE Cognigy. The connection drops roughly every 45-60 seconds, triggering a reconnect loop. This causes noticeable audio latency spikes for the end user, making the conversation feel disjointed.
We’ve implemented the standard keep-alive mechanism using the ping and pong frames as per the WebSocket spec. The backend sends a ping every 30 seconds. If a pong isn’t received within 5 seconds, the client disconnects. Here’s the relevant Kotlin snippet handling the WebSocket lifecycle:
val websocket = OkHttpClient.Builder()
.pingInterval(30, TimeUnit.SECONDS)
.build()
.newWebSocket(request, object : WebSocketListener() {
override fun onOpen(webSocket: WebSocket, response: Response) {
Log.d(TAG, "WebSocket connected")
}
override fun onClosed(webSocket: WebSocket, code: Int, reason: String) {
Log.w(TAG, "WebSocket closed: code=$code, reason=$reason")
// Reconnect logic here
}
})
The logs show code=1006 (abnormal closure) frequently. The reason string is empty. I’ve checked the Genesys Cloud logs and see no corresponding errors on the server side. The AppFoundry instance is in the same region as the Genesys Cloud org, so latency shouldn’t be a major factor.
Is there a specific configuration in the Genesys Cloud WebSocket endpoint or the Cognigy connector that might be interfering with the ping/pong cycle? I’ve tried increasing the ping interval to 45 seconds, but the drops still happen, just slightly less frequently. The audio latency seems to correlate directly with these reconnect events. Any ideas on what could be causing the abrupt closures without a proper close frame?