1.背景
微服务开发,使用Eureka做服务注册中心,Zuul做网关。A服务模块去调用B服务的方法,第一次调用会出现超时问题,报错如下:
com.netflix.hystrix.exception.HystrixRuntimeException: OrderService#plcaceOrders(String) failed and no fallback available.
Caused by:
Caused by: feign.FeignException: status 500 reading OrderService#plcaceOrders(String); content:
{"timestamp":1562332250241,"status":500,"error":"Internal Server Error","exception":"com.netflix.zuul.exception.ZuulException","message":"TIMEOUT"}
一看这个报错原因就知道是服务超时了,因此解决方案就是增加响应时间,让B在足够的时间内完成任务并返回给A。
2.解决方案
在Zuul网关的配置文件application.yml中增加如下配置:
#防止服务超时,此处设置为6秒,时长自定义
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 6000
timeout:
enabled: false
3.下面的不用看
具体报错信息:
com.netflix.hystrix.exception.HystrixRuntimeException: OrderService#plcaceOrders(String) failed and no fallback available.
at com.netflix.hystrix.AbstractCommand$22.call(AbstractCommand.java:805)
at com