WebSocket transcript stream drops after 5 minutes with asyncio reconnect loop

Problem
We’re trying to pull real-time interaction transcripts from Genesys Cloud using a Python asyncio WebSocket client. The stream starts fine, but it keeps dropping exactly after five minutes. The auto-reconnect logic fires, but the new connection just returns empty payloads instead of catching up with the active conversation. It’s weird because the same setup works perfectly for queue events. Honestly, the memory usage looks fine too. Just keeps dropping. We tried tweaking the buffer size but that didn’t help.

Code
Here’s the reconnect loop we’re running. We’re using the /api/v2/analytics/icaps/interactions endpoint with standard OAuth Bearer tokens.

async def stream_transcripts(websocket_url, ORGANIZATION_ID, RECONNECT_INTERVAL):
 while True:
 try:
 async with websockets.connect(websocket_url) as ws:
 payload = {"organizationId": ORGANIZATION_ID, "filters": ["type:interaction"]}
 await ws.send(json.dumps(payload))
 async for msg in ws:
 process_transcript(msg)
 except websockets.exceptions.ConnectionClosed as e:
 print(f"Stream dropped: {e}")
 await asyncio.sleep(RECONNECT_INTERVAL)

Error
The console spits out a 1006 close code right at the five-minute mark. Then the reconnect hits the server and immediately gets a 401 Unauthorized even though the token refresh logic is running on a separate thread. The token definitely isn’t expired since other REST calls work fine. We checked the AUTH_TOKEN_ENDPOINT and it’s returning valid JSON every time.

Question
Is there a specific header or query parameter we’re missing for the Interaction API WebSocket endpoint? The documentation mentions a X-Genesys-Request-Id but we don’t know if that affects the stream lifecycle. Also wondering if the MAX_RETRY_COUNT needs to be hardcoded to something lower than three seconds. The logs just stop updating.