很少在spring boot,eureka,zuul,ribbon framework中获得ClientException和ZuulException

时间:2017-10-28 12:44:57

标签: spring-boot netflix-eureka netflix-zuul spring-cloud-netflix

我使用Spring Boot,Eureka,Zuul,Ribbon框架配置了我的项目架构。 它工作正常,但有时(很少)得到以下例外:

  1. 引起:com.netflix.client.ClientException:负载均衡器没有客户端的可用服务器: service1
  2. 引起:com.netflix.hystrix.exception.HystrixRuntimeException: service1 超时且无可用后备。
  3. 以下是我的服务配置: 如果我错过了导致上述异常问题的任何内容,请查看并告诉我。

    eureka service application.properties:

    server.port=8070
    spring.application.name=eureka_service
    eureka.client.register-with-eureka=false
    eureka.client.fetch-registry=false
    eureka.instance.hostname=localhost
    eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:8070/eureka/
    logging.level.com.netflix.eureka=OFF
    logging.level.com.netflix.discovery=OFF
    

    zuul service application.properties:

    server.port=8071
    spring.application.name=zuul_service
    zuul.prefix=/api
    zuul.routes.service1.path=/service1/**
    zuul.routes.service1.service-id=service1
    eureka.client.register-with-eureka=true
    eureka.client.fetch-registry=true
    eureka.instance.hostname=localhost
    eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:8070/eureka/
    ribbon.eureka.enabled=true
    

    service1 application.properties:

    server.port=8072
    spring.application.name=service1
    eureka.client.register-with-eureka=true
    eureka.client.fetch-registry=true
    eureka.instance.hostname=localhost
    eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:8070/eureka/
    ribbon.eureka.enabled=true
    

    如果我需要添加任何其他配置来解决,请告诉我们? 感谢。

1 个答案:

答案 0 :(得分:0)

您可以尝试通过设置例如:

来增加功能区超时
ribbon.ReadTimeout=10000

如果以上代码无效,您可以尝试禁用超时:

hystrix.command.default.execution.timeout.enabled=false