Discussions

Ask a Question
Back to all

Immediate disconnect

While I'm connecting to ws_url sometimes the connection is working fine but in few cases it is connecting and then closes immediately.
Is there something out of these 3 points:
1.Only have frontend connect to the WebSocket 2.Use a different backend control mechanism (REST API, separate WebSocket endpoint) 3.Ensure only one client connects at a time (coordinate frontend/backend)

Session ID for reference:LiveAvatar session: 971f95e6-b861-4fb2-8818-ae6f816abc0f

Error pasted below:

2026-02-17 04:39:58,601 [ERROR] app.modules.liveavatar_client - [LIVEAVATAR] WebSocket closed during initial wait! Close code: 1000
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - [LIVEAVATAR] Messages received: 0, Session state: None
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - ================================================================================
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - [LIVEAVATAR DEBUG] IMMEDIATE CLOSE DETECTED!
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - [LIVEAVATAR DEBUG] Session ID: 971f95e6-b861-4fb2-8818-ae6f816abc0f
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - [LIVEAVATAR DEBUG] Time before close: 1001.27ms
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - [LIVEAVATAR DEBUG] Messages received: 0
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - [LIVEAVATAR DEBUG] Session state received: None
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - [LIVEAVATAR DEBUG] Close code: 1000
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - [LIVEAVATAR DEBUG] WS URL: wss://webrtc-signaling.heygen.io/v2-alpha/interactive-avatar/session/b4abff26-0bba-11f1-a2a7-06bd7d2bde6d
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - ================================================================================
2026-02-17 04:39:58,602 [ERROR] app.modules.liveavatar_client - [LIVEAVATAR] Failed to connect to WebSocket: WebSocket closed immediately with code 1000 - no session state received
Traceback (most recent call last):
  File "/app/app/modules/liveavatar_client.py", line 366, in connect_websocket
    raise RuntimeError(f"WebSocket closed immediately with code {self.ws.close_code} - no session state received")
RuntimeError: WebSocket closed immediately with code 1000 - no session state received
2026-02-17 04:39:58,603 [ERROR] app.api.streaming_routes - [session=cmj1dpm0g005wrvwxzr6rqq3k_1771303183305] [MODE_SWITCH] Failed to connect to LiveAvatar: WebSocket closed immediately with code 1000 - no session state received