Hi,
I’m building an Android assistant using the Firebase AI Logic SDK, which integrates with the Gemini Live API and uses the gemini-3.1-flash-live-preview model for real-time, multimodal interactions with continuous audio and video streaming.
The session establishes successfully, and I am receiving regular LiveSessionResumptionUpdate messages with resumption handles. However, the session consistently drops abruptly after several seconds to minutes of active use.
From our client-side logs, there are no network changes or local disconnections, but our socket suddenly encounters a java.io.EOFException inside OkHttp’s WebSocketReader.readHeader(), immediately nullifying the session. When the client attempts to stream subsequent audio/video packets, it fails with a session is closed exception.
The backend team should be able to trace this exact disconnect. Here are the specific tracking handles and logs from our failure event:
Key Backend Tracing Metadata
- Last Captured Resumption Handle: 0a7879fa-4762-4f56-a042-03ba6ada7..
- Timestamp of Resumption Capture: 08-26 12:11:56.863
- Timestamp of Abrupt Disconnect: 08-26 12:12:14.957 (approx. 18 seconds after the handle was captured)
- Client Device Environment: Android 16 (API 36 / userdebug build)
- Streaming Mode: CONTINUOUS (multimodal)
Relevant Logcat Snippet
// 1. Session is active, capturing resumption handles successfully
08-26 12:11:56.863 16010 21382 D FirebaseGeminiClient: Received LiveServerMessage:
com.google.firebase.ai.type.LiveSessionResumptionUpdate@bda9e33
08-26 12:11:56.863 16010 21382 D FirebaseGeminiClient: Resumption handle captured: 0a7879fa-4762-4f56-a042-03ba6ada752b
// 2. ~18 seconds later, streaming packets suddenly fail due to session closure
08-26 12:12:14.957 16010 21382 W FirebaseGeminiClient: sendAudioRealtime failed: session is closed or null (not reconnecting).
08-26 12:12:14.958 16010 21382 E BackgroundAssistant: Assistant error: sendAudioRealtime failed: session is closed
// 3. Underlying OkHttp WebSocket loop crashes with EOF Exception
08-26 12:12:14.970 16010 21382 E BackgroundAssistant: Assistant error: Error sending video realtime
08-26 12:12:14.970 16010 21382 E BackgroundAssistant: com.google.firebase.ai.type.UnknownException: Something unexpected happened. at com.google.firebase.ai.type.FirebaseAIException$Companion.from$com_google_firebase_ai_logic_firebase_ai(Exceptions.kt:51)
at com.google.firebase.ai.type.LiveSession.sendVideoRealtime(LiveSession.kt:788)
at com.android.ai.samples.geminilivetodo.core.ai.FirebaseGeminiClientImpl.sendVideoRealtime(FirebaseGeminiClientImpl.kt:154)
Caused by: java.io.EOFException
at okio.RealBufferedSource.require(RealBufferedSource.kt:223)
at okio.RealBufferedSource.readByte(RealBufferedSource.kt:233)
at okhttp3.internal.ws.WebSocketReader.readHeader(WebSocketReader.kt:119)
at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:102)
at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:293)
at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
Few Questions for the Google Engineering Team:
- Why is the backend server tearing down the TCP socket abruptly (EOF) instead of sending a graceful WebSocket close frame?
- Is there a strict server-side maximum payload limit for real-time video chunk frames that is
triggering this silent drop?
Any insights or investigation on the backend logs for resumption handle 0a7879fa-4762-4f56-a042-03ba6ada7.. would be highly appreciated!
Thank you!