zuul调用时间超过1s返回 timeout错误
zuul遇到的问题,每个请求超过1s就会被熔断,给调用方返回timeout
在yml配置里加入以下配置,解决了这个问题
问题在于zuul默认集成了hystrix,可以在配置文件将hystrix给关闭,然后ribbon的超时时间也要设置
我依赖的zuul版本
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<version>1.4.2.RELEASE</version>
</dependency>
zuul:
max:
host:
connections: 1000000
host:
socket-timeout-millis: 60000
connect-timeout-millis: 60000
routes:
api-pay:
path: /route/**
serviceId: route-server
api-push:
path: /push/**
serviceId: push-server
ribbon:
ReadTimeout: 15000 # 单位毫秒数
SocketTimeout: 60000
hystrix:
command:
default:
execution:
timeout:
enabled: true #是否开启
isolation:
thread:
timeoutInMilliseconds: 20000 # 超时时间
ribbon:
ReadTimeout: 15000
ConnectTimeout: 20000