java - Spring Cloud Gateway:发布大文件时出现“连接已在响应之前关闭,同时发送请求正文”错误
问题描述
我在 spring 云网关后面运行了 spring boot 应用程序。
春季启动应用程序控制器:
@PostMapping(value = "hi")
public String postHi(@RequestHeader HttpHeaders headers, HttpServletRequest request) {
return request.getHeader("Content-Length");
}
Spring Cloud 网关路由配置:
spring:
cloud:
gateway:
routes:
- id: hi
uri: http://localhost:8080/hi
predicates:
- Path=/hi/**
因此,当我通过邮递员请求上传小文件(大小:1000 KB)时,我没有收到任何错误,但是当文件很大(大小:10 MO)时,我收到以下错误:
{
"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"
}
使用此堆栈:
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:
这是重现该问题的示例: https ://github.com/jemmali-git/examples.git
解决方案
推荐阅读
- python - 如何从 for 循环中创建一个全局变量
- postgresql - 如何在 PostgreSQL 中使用时间戳转换为日期表达式创建唯一的可延迟约束?
- python - 来自另一个模块类的 Python 导入方法
- java - java, spring boot 在运行时自动生成getter和setter
- sql - 使用 in (select ...) 子句进行查询优化
- javascript - 使用 Charts.js 从分组的 JSON 对象绘制多线图
- powershell - 有什么方法可以从 Powershell 命令行打开 Active Directory 用户和计算机中的用户属性?
- thymeleaf - 如何在无状态编程中从 UI 取消正在运行的查询
- swift - 仅使用 UITableView 更新 JSON 数组记录
- javascript - 有没有办法将 Google 文档分割成多个 PDF?