• springcloud 搭建遇到的问题网关Connection has been closed BEFORE response, while sending request body


    @PostMapping(value = "hi")
    public String postHi(@RequestHeader HttpHeaders headers, HttpServletRequest request) {
      return request.getHeader("Content-Length");
    }
    

    Spring cloud gateway route configuration :

    spring:
      cloud:
        gateway:
          routes:
            - id: hi
              uri: http://localhost:8080/hi
              predicates:
                - Path=/hi/**
    

    So when I upload small file (size:1000 KB) via a postman request I get no error but when the file is large (size :10 MO) I get the following error :

    {
        "timestamp": "2019-12-10T20:52:33.554+0000",
        "path": "/hi",
        "status": 500,
        "error": "Internal Server Error",
        "message": "Connection has been closed BEFORE response, while sending request body",
        "requestId": "ad589017"
    }
    

    with this stack :

    reactor.netty.http.client.PrematureCloseException: Connection has been closed BEFORE response, while sending request body
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
    Error has been observed at the following site(s):
        |_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
        |_ checkpoint ⇢ HTTP POST "/hi" [ExceptionHandlingWebHandler]
    Stack trace:

     [reactor-http-epoll-8] ERROR [studyX-gateway,cf0edfec528a956e,cf0edfec528a956e,true] o.s.b.a.w.r.error.AbstractErrorWebExceptionHandler:122 - [840b107e-14] 500 Server Error for HTTP POST "/api/xxx/"
    reactor.netty.http.client.PrematureCloseException: Connection has been closed BEFORE response, while sending request body
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
    Error has been observed at the following site(s):
    |_ checkpoint ⇢ org.springframework.web.cors.reactive.CorsWebFilter [DefaultWebFilterChain]
    |_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
    |_ checkpoint ⇢ org.springframework.cloud.sleuth.instrument.web.TraceWebFilter [DefaultWebFilterChain]
    |_ checkpoint ⇢ HTTP POST "/api/xxx/" [ExceptionHandlingWebHandler]
    Stack trace:



    解决:下游配置超时时间
    server:
    port: 6000
    tomcat:
    connection-timeout: 6000
     
     
  • 相关阅读:
    毛笔算法 毛笔签名效果
    手写输入控件
    全栈工程师成长路线
    配置msdtc
    流行的广告轮播(图片轮播)JS代码!!
    水晶报表放上去网站会爆:bobj错误的
    查询所有存储过程
    VB.NET and C# Comparison
    SQL查询案例:多行转换为一行
    SQL Server行列转换[转]
  • 原文地址:https://www.cnblogs.com/d0minic/p/15989212.html
Copyright © 2020-2023  润新知