Search code examples
spring-cloudnetflix-zuul

Spring Cloud: Zuul java.net.SocketException: Broken pipe


I am doing some stress test of a simple spring cloud app backed by a zuul proxy service Sporadically we have a broken pipe exception due to a stale connection between Zuul and the service. I configure Zuul with diferent configuration options without success:

hystrix:
  command:
    default:
      execution:
        isolation:
          strategy: THREAD
          thread:
            timeoutInMilliseconds: 61000


ribbon:
  ReadTimeout: 60000
  ConnectTimeout: 6000

zuul:
  host:
    socket-timeout-millis: 60000
    connect-timeout-millis: 60000

The exception is as follows:

com.netflix.zuul.exception.ZuulException: Forwarding error at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:151) ~[router.jar!/:0.0.1] at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:114) ~[router.jar!/:0.0.1] at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:112) ~[zuul-core-1.0.28.jar!/:na]

Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: query-serviceRibbonCommand failed and no fallback available. at com.netflix.hystrix.AbstractCommand$20.call(AbstractCommand.java:816) ~[hystrix-core-1.4.0-RC6.jar!/:na] at com.netflix.hystrix.AbstractCommand$20.call(AbstractCommand.java:798) ~[hystrix-core-1.4.0-RC6.jar!/:na] at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:77) ~[rxjava-1.0.4.jar!/:1.0.4] at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.4.jar!/:1.0.4]

Caused by: java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.8.0_45] at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109) ~[na:1.8.0_45] at java.net.SocketOutputStream.write(SocketOutputStream.java:153) ~[na:1.8.0_45] at org.apache.http.impl.io.AbstractSessionOutputBuffer.flushBuffer(AbstractSessionOutputBuffer.java:159) ~[httpcore-4.3.3.jar!/:4.3.3] ... at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55) ~[rxjava-1.0.4.jar!/:1.0.4] at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:185) ~[ribbon-loadbalancer-2.0-RC13.jar!/:na] at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:180


Solution

  • I had run out from the same problem: I have resolved it by adding zuul execution timeout to the application.yml of zuul server:

    # Increase the Hystrix timeout to 60s (globally)
    hystrix:
      command:
        default:
          execution:
            isolation:
              thread:
                timeoutInMilliseconds: 60000
    

    Please refer to this thread on netflix issues: https://github.com/spring-cloud/spring-cloud-netflix/issues/321