2017-08-15 53 views
1

我有一個配置文件作爲zuul服務器:春雲 - 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] 

任何人有這種情況的解決方案? 謝謝!

+0

應設置錐超時長於絲帶超時。 – LHCHIN

回答

1

嘗試在ZUUL配置中爲Ribbon添加超時。
以下將設置超時2分鐘。

ribbon: 
    ConnectTimeout: 120000 
    ReadTimeout: 120000