我正在尝试在Zuul网关中启用重试功能,并且能够在本地工作,但是当我将网关部署到PCF时,我在 zuul.retryable=true
时收到以下错误:
{
"timestamp": 1524669167094,
"status": 500,
"error": "Internal Server Error",
"exception": "com.netflix.zuul.exception.ZuulException",
"message": "COMMAND_EXCEPTION"
}
相关日志给出了以下异常详细信息:
com.netflix.zuul.exception.ZuulException: Forwarding error
Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: spring-demo failed and no fallback available.
Caused by: org.apache.http.NoHttpResponseException: spring-demo.example.com:443 failed to respond
我已经测试了 spring-demo.example.com
并且它在200毫秒内正确响应(200),当我删除 zuul.retryable
属性时,Zuul也能够得到有效的响应(尽管它不会重试任何错误状态代码或超时) .
当我在本地运行时,我可以看到 RibbonLoadBalancedRetryPolicy
在超时时尝试不同的实例,或者在获得500时尝试使用's only in PCF that I' m得到错误 . 我已经验证了实例出现在PCF Eureka中并且还尝试增加连接/读取/ hystrix超时 .
这是服务布局:
-
"working" app的实例连接到Eureka作为"spring-demo"
-
"broken"个应用程序连接到Eureka的实例为"spring-demo"(超时或返回500)
-
Zuul与尤里卡相连
Zuul application.yml:
zuul:
ignoredServices: '*'
ignoredPatterns: '/**/actuator/**'
retryable: true
routes:
spring-demo: '/spring-demo/**'
ribbon:
retryableStatusCodes: 404, 500
MaxAutoRetries: 1
MaxAutoRetriesNextServer: 5
OkRetryOnConnectionErrors: true
Gradle依赖版本:
-
Spring Boot 1.5.12.RELEASE
-
Spring Cloud Edgware.SR3
-
Pivotal Services 1.6.3.RELEASE
-
spring-boot-starter-web
-
spring-boot-starter-actuator
-
spring-cloud-starter-netflix-zuul
-
spring 重试
-
spring-cloud-services-starter-service-registry
-
spring-cloud-services-starter-circuit-breaker