504 GATEWAY_TIMEOUT \“Response took longer than timeout:PTxxx问题处理
spring cloub项目通过访问服务的http接口偶尔会出现“504 GATEWAY_TIMEOUT "Response took longer than timeout:PTxxx”的异常。通过测试发现是服务的接口还未返回结果时,gateway就以几个返回了异常,判断出是gateway的HTTP接口的responseTimeout配置原因。response-timeout必须指定为java.
·
问题描述
spring cloub项目通过访问服务的http接口偶尔会出现“504 GATEWAY_TIMEOUT "Response took longer than timeout:PTxxx”的异常。
问题处理
通过测试发现是服务的接口还未返回结果时,gateway就以几个返回了异常,判断出是gateway的HTTP接口的responseTimeout配置原因。
原有配置:
spring:
cloud:
gateway:
httpclient:
connect-timeout: 1000
response-timeout: 5s
修改后:
spring:
cloud:
gateway:
httpclient:
connect-timeout: 1000
response-timeout: 10s
gateway超时配置
全局http超时:
connect-timeout必须以毫秒为单位指定。
response-timeout必须指定为java.time.Duration
spring:
cloud:
gateway:
httpclient:
connect-timeout: 1000
response-timeout: 10s
单个路由配置
这个配置未测试
- id: per_route_timeouts
uri: https://example.org
predicates:
- name: Path
args:
pattern: /delay/{timeout}
metadata:
response-timeout: 200
connect-timeout: 200
更多推荐
已为社区贡献1条内容
所有评论(0)