gpt4 book ai didi

Spring Cloud - Zuul 无法设置超时

转载 作者:行者123 更新时间:2023-12-01 14:38:39 25 4
gpt4 key购买 nike

我有一个带有配置文件的 zuul 服务器:

server:
port: 9090
eureka:
client:
serviceUrl:
defaultZone: http://172.16.5.147:8761/eureka/
instance:
leaseRenewalIntervalInSeconds: 30
hostname: dev-zuulserver
non-secure-port: 80
zuul:
prefix: /v1
sensitiveHeaders: Cookie, Set-Cookie
ignoredHeaders: Access-Control-Allow-Origin
host:
connect-timeout-millis: 60000 # starting the connection
socket-timeout-millis: 120000 # monitor the continuous incoming data flow
ribbon:
eureka:
enabled: true
ReadTimeout: 120000
ConnectTimeout: 3000
hystrix:
command:
default:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 60000

我有一些超时时间更长(超过一分钟)的查询。但是,我的所有请求总是因超时而出错,请求时间总是小于 6000 毫秒。

zuul 显示此异常:

Caused by: java.lang.RuntimeException: java.net.SocketTimeoutException: Read timed out

at rx.exceptions.Exceptions.propagate(Exceptions.java:58) ~[rxjava-1.1.10.jar!/:1.1.10]
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:465) ~[rxjava-1.1.10.jar!/:1.1.10] at rx.observables.BlockingObservable.single(BlockingObservable.java:342) ~[rxjava-1.1.10.jar!/:1.1.10] at com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:117) ~[ribbon-loadbalancer-2.2.2.jar!/:2.2.2] ... 133 common frames omitted Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_131] at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[na:1.8.0_131] at java.net.SocketInputStream.read(SocketInputStream.java:171) ~[na:1.8.0_131] at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_131] at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) ~[httpcore-4.4.6.jar!/:4.4.6] at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) ~[httpcore-4.4.6.jar!/:4.4.6] at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:282) ~[httpcore-4.4.6.jar!/:4.4.6] at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[httpclient-4.5.3.jar!/:4.5.3] at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[httpclient-4.5.3.jar!/:4.5.3] at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[httpcore-4.4.6.jar!/:4.4.6] at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163) ~[httpcore-4.4.6.jar!/:4.4.6] at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165) ~[httpclient-4.5.3.jar!/:4.5.3] at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[httpcore-4.4.6.jar!/:4.4.6] at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[httpcore-4.4.6.jar!/:4.4.6]



有没有人对这种情况有解决方案?

谢谢!

最佳答案

尝试在 ZUUL 配置中为 Ribbon 添加超时。
以下将设置超时 2 分钟。

ribbon:
ConnectTimeout: 120000
ReadTimeout: 120000

关于Spring Cloud - Zuul 无法设置超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45689648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com