简体   繁体   English

Spring 云网关30s超时,

[英]Spring Cloud gateway is timing out in 30s,

I'm using spring cloud gateway as my gateway application.我使用 spring 云网关作为我的网关应用程序。 When I try to call the api directly it succeeds, but when called through it times out in 30s.I'm trying to upload a multipart file which is around 250MB.当我尝试直接调用 api 时它会成功,但是通过它调用时会在 30 秒内超时。我正在尝试上传一个大约 250MB 的多部分文件。 directly calling the application it succeeds in around 6-7 minutes.直接调用应用程序它在大约 6-7 分钟内成功。

Spring cloud api gateway timeout configuration Spring云api网关超时配置

- id:  xyz
          uri: ${xyz.----}
          predicates:
            - Path=/${xyz}/**
          filters:
            - RewritePath=/${xyz}/(?<oldPath>.*), /${oldPath}
            - CachingRequestBody
            - SignResponseBody
            - name: RequestSize
              args:
               maxSize: 1024MB
          metadata:
            response-timeout: 600000
            connect-timeout: 600000
            serviceName: ${xyz}




public Customizer<ReactiveResilience4JCircuitBreakerFactory> defaultCustomizer() {
        return factory -> factory.configureDefault(id -> new Resilience4JConfigBuilder(id)
                .circuitBreakerConfig(CircuitBreakerConfig.ofDefaults())
                .timeLimiterConfig(TimeLimiterConfig.custom().timeoutDuration(Duration.ofMillis(600000)).build())
                .build());



cloud:
    gateway:
      httpclient:
        connect-timeout: 600000
        response-timeout: 600s
      default-filters:
        - name: OrderedCircuitBreaker
          args:
            name: global-fallback
            fallbackUri: forward:/fallback

Any help will be highly appreciated任何帮助将不胜感激

Hi Guys I found the answer, Every request in gateway goes through a set of filter.嗨,伙计们,我找到了答案,网关中的每个请求都经过一组过滤器。 as you can see a filter CachedRequestBody.如您所见,过滤器 CachedRequestBody。 this filter caches the request body.此过滤器缓存请求正文。 which in case was very large and api gateway didn't have space for that so it timeout with java heap space error.如果它非常大并且 api 网关没有空间,因此它会因 java 堆空间错误而超时。 I removed that filter and now it's working fine.我删除了那个过滤器,现在它工作正常。 Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM