Skip to content

Timout calling MoonshotChatModel.call() #1416

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
JunweiDuan opened this issue Sep 26, 2024 · 3 comments
Closed

Timout calling MoonshotChatModel.call() #1416

JunweiDuan opened this issue Sep 26, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@JunweiDuan
Copy link

Bug description
timeout when calling OpenAI/MoonShot API
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://api.moonshot.cn/v1/chat/completions": timeout
at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.createResourceAccessException(DefaultRestClient.java:578)
at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.exchangeInternal(DefaultRestClient.java:501)
at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.retrieve(DefaultRestClient.java:463)
at org.springframework.ai.moonshot.api.MoonshotApi.chatCompletionEntity(MoonshotApi.java:584)
at org.springframework.ai.moonshot.MoonshotChatModel.lambda$call$0(MoonshotChatModel.java:140)
at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:344)
at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:217)
at org.springframework.ai.moonshot.MoonshotChatModel.call(MoonshotChatModel.java:140)
at org.springframework.ai.chat.model.ChatModel.call(ChatModel.java:33)
at com.fisher.common.ai.service.impl.MoonshotAiServiceImpl.chat(MoonshotAiServiceImpl.java:27)
at com.fisher.news.api.FinanceNewsApi.parseArticleToEvent(FinanceNewsApi.java:130)
at com.fisher.news.api.FinanceNewsApi.getFinNewsEventByArticle(FinanceNewsApi.java:57)
at com.fisher.news.service.impl.NewsFinEventServiceImpl.crawlerLatestNewsFinEvent(NewsFinEventServiceImpl.java:36)
at com.fisher.job.news.NewsFinEventCrawlerProcessor.process(NewsFinEventCrawlerProcessor.java:39)
at tech.powerjob.worker.core.tracker.task.light.LightTaskTracker.processTask(LightTaskTracker.java:211)
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.net.SocketTimeoutException: timeout
at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.kt:675)
at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.kt:684)
at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.kt:143)
at okhttp3.internal.http2.Http2ExchangeCodec.readResponseHeaders(Http2ExchangeCodec.kt:96)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:106)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:79)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
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.execute(RealCall.kt:154)
at org.springframework.http.client.OkHttp3ClientHttpRequest.executeInternal(OkHttp3ClientHttpRequest.java:95)
at org.springframework.http.client.AbstractStreamingClientHttpRequest.executeInternal(AbstractStreamingClientHttpRequest.java:70)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:66)
at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.exchangeInternal(DefaultRestClient.java:495)
... 18 common frames omitted

Environment
Spring AI version: 1.0.0-SNAPSHOT
Java version: JDK17
No use Vector and others.

Steps to reproduce
MoonshotChatModel.call() .

Expected behavior
Get the right data from MoonShot AI interface.

Minimal Complete Reproducible example
MoonshotChatModel

@ThomasVitale
Copy link
Contributor

This seems to be the same problem described in #1016, and happening when okhttp3 is in the classpath (resulting in Spring Boot using it as the implementation of RestClient).

@alexcheng1982
Copy link
Contributor

Timeout can happen for various reasons, maybe the server was just too slow to respond. You can provide a RestClient.Builder bean with custom timeout settings to increase the default timeout.

@markpollack
Copy link
Member

closing this and will track in #1016

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants