Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Live API: no way to observe session close or connection errors after setup

Đang mở
#1,153 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@hemasekhar-p đang làm issue này rồi.

Từ ngày 3/8/2026.

  • #1154 của @subhashpolisetti — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

priority: p3 type: feature request

Summary

After a Live session is established, a caller has no way to be notified that it ended. When the server closes the session (e.g. after GoAway) or the WebSocket drops, AsyncLive.GenAiWebSocketClient only logs onClosed/onFailure nothing reaches the receive() message consumer or any future, so the application can't react. receive() itself returns an already-completed future (its Javadoc notes it only signals registration), so it can't carry the signal either.

Root cause

In AsyncLive.GenAiWebSocketClient, once sessionFuture is done (i.e. for the whole active session) these just log:

public void onClosed(WebSocket webSocket, int code, String reason) {
    logger.log(Level.INFO, "Live session closed ...");
    if (!sessionFuture.isDone()) { sessionFuture.completeExceptionally(...); }  // else: only logged
}

public void onFailure(WebSocket webSocket, Throwable t, @Nullable Response response) {
    logger.log(Level.SEVERE, "Error during live session", t);
    if (!sessionFuture.isDone()) { sessionFuture.completeExceptionally(t); }    // else: only logged
}

Impact

Found while building the Gemini Live API integration for langchain4j: the wrapper can't tell the application when a session ends. A listen-only voice agent is never notified that the connection dropped the only signal today is an exception on the next send.

Suggested fix

A backward-compatible overload of receive(...), with onError/onClose invoked from onFailure/onClosed after setup (terminal, mutually exclusive, nullable); the existing receive(Consumer) delegates to it:

public CompletableFuture<Void> receive(
    Consumer<LiveServerMessage> onMessage, Consumer<Throwable> onError, Runnable onClose)

Open to a different shape (e.g. a listener interface) if you'd prefer.

Environment

com.google.genai:google-genai 1.62.0, and unchanged on current main (1.65.0-SNAPSHOT). Gemini Live API, Java.

Ngôn ngữ chính
Java
Star
398
Fork
126
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
71

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của googleapis/java-genai

Tất cả issue của googleapis/java-genai

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.