小工具知识网

当前位置: 首页 > 行业知识 > 504 GATEWAY

行业知识

504 GATEWAY

2026-11-11 01:17:09 来源:互联网转载

问题描述

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

上一篇:云空间账号怎么申请?

下一篇:oculus怎么连接服务器?