-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
live[Component] This issue is related to live, voice and video chat[Component] This issue is related to live, voice and video chat
Description
Bug Description
WebSocket connection to Gemini Live API randomly times out with ConnectionClosedError: no close frame received or sent, causing live agent sessions to terminate unexpectedly.
Environment
- ADK Python Version: 1.15.1
- Python Version: 3.13.3
- Operating System: macOS (darwin 25.0.0)
- Architecture: aarch64 (Apple Silicon)
Steps to Reproduce
- Start ADK web server with live WebSocket endpoint (
/run_live) - Establish WebSocket connection to Gemini Live API through ADK
- Maintain connection for extended period or during heavy usage
- Connection randomly times out and closes unexpectedly
Expected Behavior
WebSocket connection should remain stable and handle temporary network issues gracefully with proper reconnection mechanisms.
Actual Behavior
Connection abruptly terminates with error code 1011 (internal error) and the message "no close frame received or sent".
Error Log
2025-09-28 14:00:38,487 - ERROR - base_llm_flow.py:200 - Connection closed: no close frame received or sent.
2025-09-28 14:00:38,510 - ERROR - websocket_routes.py:199 - Error during live websocket communication: no close frame received or sent
Traceback (most recent call last):
File "/Users/qianyunzhu/.local/share/uv/python/cpython-3.13.3-macos-aarch64-none/lib/python3.13/asyncio/selector_events.py", line 980, in _read_ready__get_buffer
nbytes = self._sock.recv_into(buf)
TimeoutError: [Errno 60] Operation timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/qianyunzhu/Myproject/adk-python-ai-platform/src/seirobotics/ai/routers/conversation/websocket_routes.py", line 195, in agent_live_run
task.result()
...
File "/Users/qianyunzhu/Myproject/adk-python-ai-platform/.venv/lib/python3.13/site-packages/google/genai/live.py", line 521, in _receive
raw_response = await self._ws.recv(decode=False)
File "/Users/qianyunzhu/Myproject/adk-python-ai-platform/.venv/lib/python3.13/site-packages/websockets/asyncio/connection.py", line 322, in recv
raise self.protocol.close_exc from self.recv_exc
websockets.exceptions.ConnectionClosedError: no close frame received or sent
Stack Trace Analysis
The error originates from:
google.genai.live.py:521- Low-level WebSocket receive operationgemini_llm_connection.py:149- ADK's Gemini connection handlerbase_llm_flow.py:299- LLM flow processingwebsocket_routes.py:127- Application WebSocket routing
Potential Root Causes
- Network timeout issues with Gemini Live API
- Missing heartbeat/keepalive mechanism for long-lived connections
- Insufficient timeout configuration for WebSocket connections
- Possible API quota or rate limiting on Google's side
Impact
- Live agent sessions terminate unexpectedly
- Poor user experience due to connection instability
- No automatic recovery mechanism available
Workaround
Currently implementing custom error handling and reconnection logic in application code, but this should be handled at the SDK level.
Additional Context
This issue occurs intermittently and seems to be more frequent during:
- Extended conversation sessions
- High API usage periods
- Network instability
Suggested Solutions
- Implement automatic reconnection with exponential backoff
- Add configurable timeout parameters for WebSocket connections
- Implement heartbeat/ping mechanism to maintain connection health
- Better error classification and handling for different types of connection failures
- Add connection status monitoring and recovery mechanisms
Metadata
Metadata
Assignees
Labels
live[Component] This issue is related to live, voice and video chat[Component] This issue is related to live, voice and video chat