feat: surface Live API session close and error events to receive() callers - #1154
subhashpolisetti wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…llers After setup, GenAiWebSocketClient only logs onClosed/onFailure — they never reach the receive() message consumer or any future, so a caller cannot react when the server closes a live session or the WebSocket drops. receive() itself returns an already-completed future (registration only), so it can't carry this either. Add an overload receive(onMessage, onError, onClose) that also surfaces error and close. The existing receive(Consumer) delegates to it, so its behavior is unchanged. onError/onClose are terminal and mutually exclusive (failure -> onError, normal close -> onClose) and may be null. Fixes googleapis#1153
97a355a to
3967e46
Compare
|
@googlebot I signed it! |
|
Thanks for this — we hit the same gap in production and would very much like it merged. One suggestion so it also covers server-initiated closes on the OkHttp client: On OkHttp, Concrete case we observed with 1.73.0 on Vertex: a With this PR as written,
Until this lands we're working around it with a |
What
After a Live session is established,
GenAiWebSocketClientonly logsonClosed/onFailure— they never reach thereceive()consumer or any future, so a caller can't tell when the server closes the session or the connection drops.This adds a backward-compatible overload that surfaces those events:
onError/onCloseare invoked fromonFailure/onClosedafter setup (terminal, mutually exclusive, nullable). The existingreceive(Consumer)delegates to the overload, so its behavior is unchanged.Why
Found building the Gemini Live API integration for langchain4j — the wrapper had no way to notify the app when a session ends. See #1153.
Tests
AsyncLiveTestcovers the close and error paths.Fixes #1153