我有一个配置文件的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显示了这个例外:
引起: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]
在rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:465)〜[rxjava-1.1.10.jar!/:1.1.10] 在rx.observables.BlockingObservable.single(BlockingObservable.java:342)〜[rxjava-1.1.10.jar!/:1.1.10] 在com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:117)〜[ribbon-loadbalancer-2.2.2.jar!/:2.2.2] ...省略了133个常用帧 引起:java.net.SocketTimeoutException:读取超时 at java.net.SocketInputStream.socketRead0(Native Method)〜[na:1.8.0_131] 在java.net.SocketInputStream.socketRead(SocketInputStream.java:116)〜[na:1.8.0_131] 在java.net.SocketInputStream.read(SocketInputStream.java:171)〜[na:1.8.0_131] 在java.net.SocketInputStream.read(SocketInputStream.java:141)〜[na:1.8.0_131] 在org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)〜[httpcore-4.4.6.jar!/:4.4.6] 在org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)〜[httpcore-4.4.6.jar!/:4.4.6] 在org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:282)〜[httpcore-4.4.6.jar!/:4.4.6] 在org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)~ [httpclient-4.5.3.jar!/:4.5.3] 在org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)〜[httpclient-4.5.3.jar!/:4.5.3] 在org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)〜[httpcore-4.4.6.jar!/:4.4.6] 在org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)〜[httpcore-4.4.6.jar!/:4.4.6] 在org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165)〜[httpclient-4.5.3.jar!/:4.5.3] 在org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)〜[httpcore-4.4.6.jar!/:4.4.6] 在org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)〜[httpcore-4.4.6.jar!/:4.4.6]
有没有人为这种情况提供解决方案?
谢谢!
答案 0 :(得分:1)
尝试在ZUUL配置中为Ribbon添加超时。
以下将设置超时2分钟。
ribbon:
ConnectTimeout: 120000
ReadTimeout: 120000