-
Notifications
You must be signed in to change notification settings - Fork 212
Description
Description of the bug:
This bug report details a SocketTimeoutException encountered during the generation of content using the Google AI Generative AI client library. The error message indicates that the request timed out after 80 seconds while waiting for a response from the server.
Actual vs expected behavior:
Steps to Reproduce:
- Use the Google AI Generative AI client library to generate content.
- The specific steps to reproduce may vary depending on the exact usage of the library, but the issue is likely to occur when the server response takes longer than 80 seconds.
Actual Behavior:
- An UnknownException is thrown with the message "Something unexpected happened."
- The cause of the exception is a SocketTimeoutException indicating the request timed out.
Expected Behavior:
- The request should successfully complete and return the generated content within a reasonable timeframe.
- If a timeout occurs, a more informative error message should be provided, specifying the timeout duration.
Any other information you'd like to share?
Additional Information:
The stack trace points to the Http2Stream$StreamTimeout class within OkHttp, the HTTP client library used by the Generative AI client.
The timeout period is set to 80 seconds in the URL for the request.
Possible Causes:
The server may be overloaded and taking a long time to respond.
There may be network issues causing delays in communication.
The timeout value set for the request may be too low.
Recommendations:
Investigate the cause of the slow server response and address any performance bottlenecks.
Consider increasing the timeout value for the request if appropriate.
The Generative AI client library should provide a more informative error message when a timeout occurs.
Additional Notes:
This bug report is based on the provided log snippet. Further investigation may be required to pinpoint the exact cause of the issue.
I hope this fills out all the details for this bug report.
https://gist.github.com/surajsahani/f07a99c99a204c145f84fccae27f805e
Another Logcat
2024-11-25 14:03:17.580 6531-6531 SummarizeViewModel_API org.oscar.kb E API error: An unexpected error occurred
com.google.ai.client.generativeai.type.UnknownException: Something unexpected happened.
at com.google.ai.client.generativeai.type.GoogleGenerativeAIException$Companion.from(Exceptions.kt:57)
at com.google.ai.client.generativeai.GenerativeModel$generateContentStream$1.invokeSuspend(GenerativeModel.kt:120)
at com.google.ai.client.generativeai.GenerativeModel$generateContentStream$1.invoke(GenerativeModel.kt:0)
at com.google.ai.client.generativeai.GenerativeModel$generateContentStream$1.invoke(GenerativeModel.kt:0)
at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:115)
at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1$1.invokeSuspend(SafeCollector.common.kt:0)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:68)
at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:205)
at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
at io.ktor.util.pipeline.SuspendFunctionGun.access$resumeRootWith(SuspendFunctionGun.kt:11)
at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:55)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:222)
at android.os.Looper.loop(Looper.java:314)
at android.app.ActivityThread.main(ActivityThread.java:8716)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:565)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
Caused by: io.ktor.client.network.sockets.ConnectTimeoutException: Connect timeout has expired [url=https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:streamGenerateContent?alt=sse, connect_timeout=unknown ms]
at io.ktor.client.plugins.HttpTimeoutKt.ConnectTimeoutException(HttpTimeout.kt:213)
at io.ktor.client.engine.okhttp.OkUtilsKt.mapOkHttpException(OkUtils.kt:78)
at io.ktor.client.engine.okhttp.OkUtilsKt.access$mapOkHttpException(OkUtils.kt:1)
at io.ktor.client.engine.okhttp.OkHttpCallback.onFailure(OkUtils.kt:39)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:525)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/172.217.174.74 (port 443) from /192.0.0.4 (port 55972) after 10000ms
at libcore.io.IoBridge.connectErrno(IoBridge.java:235)
at libcore.io.IoBridge.connect(IoBridge.java:179)
at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
at java.net.Socket.connect(Socket.java:646)
at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128)
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295)
2024-11-25 14:03:17.582 6531-6531 SummarizeViewModel_API org.oscar.kb E at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207)
at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
... 3 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/2404:6800:4009:815::200a (port 443) from /2409:40e6:c:f833:8000:: (port 36474) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/2404:6800:4009:803::200a (port 443) from /2409:40e6:c:f833:8000:: (port 59092) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/2404:6800:4009:806::200a (port 443) from /2409:40e6:c:f833:8000:: (port 49000) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/2404:6800:4009:814::200a (port 443) from /2409:40e6:c:f833:8000:: (port 41326) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.77.42 (port 443) from /192.0.0.4 (port 54894) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.182.202 (port 443) from /192.0.0.4 (port 47606) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.182.234 (port 443) from /192.0.0.4 (port 56968) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.183.10 (port 443) from /192.0.0.4 (port 33992) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.183.138 (port 443) from /192.0.0.4 (port 52056) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.183.170 (port 443) from /192.0.0.4 (port 60942) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.183.202 (port 443) from /192.0.0.4 (port 34182) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.66.10 (port 443) from /192.0.0.4 (port 44908) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.199.138 (port 443) from /192.0.0.4 (port 54136) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.199.170 (port 443) from /192.0.0.4 (port 50786) after 10000ms
... 28 more
2024-11-25 14:03:17.582 6531-6531 SummarizeViewModel_API org.oscar.kb E Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.251.42.106 (port 443) from /192.0.0.4 (port 49806) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.70.106 (port 443) from /192.0.0.4 (port 45426) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.70.42 (port 443) from /192.0.0.4 (port 49116) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.70.74 (port 443) from /192.0.0.4 (port 55484) after 10000ms
... 28 more
Suppressed: java.net.SocketTimeoutException: failed to connect to generativelanguage.googleapis.com/142.250.71.106 (port 443) from /192.0.0.4 (port 46230) after 10000ms
... 28 more