【发布时间】:2018-11-22 08:49:29
【问题描述】:
我正在开发 webapp,它在后端使用 Spring Boot 2.0。 对于一些用户,我看到了这种错误:
Failed to parse multipart servlet request; nested exception is
java.io.IOException:
org.apache.tomcat.util.http.fileupload.FileUploadBase
$IOFileUploadException: Processing of multipart/form-data request
failed. Unexpected EOF read on the socket]
org.springframework.web.multipart.MultipartException: Failed to parse
multipart servlet request; nested exception is java.io.IOException:
org.apache.tomcat.util.http.fileupload.FileUploadBase
$IOFileUploadException: Processing of multipart/form-data request
failed. Unexpected EOF read on the socket at
org.springframework.web.multipart.support.
StandardMultipartHttpServletRequest.
handleParseFailure(StandardMultipartHttpServletRequest.java:122) at
org.springframework.web.multipart.support.
StandardMultipartHttpServletRequest.
parseRequest(StandardMultipartHttpServletRequest.java:113) at
org.springframework.web.multipart.support.
StandardMultipartHttpServletRequest.<init
(StandardMultipartHttpServletRequest.java:86) at
org.springframework.web.multipart.support.
StandardServletMultipartResolver.
resolveMultipart(StandardServletMultipartResolver.java:93) at
org.springframework.web.servlet.DispatcherServlet.
checkMultipart(DispatcherServlet.java:1128) at
org.springframework.web.servlet.DispatcherServlet.
doDispatch(DispatcherServlet.java:960) at
org.springframework.web.servlet.DispatcherServlet.
doService(DispatcherServlet.java:925)...
你能帮我理解这个问题的根源吗?我在服务器上使用这段代码,看起来不错:
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public ResponseEntity<String> upload(HttpSession session,
MultipartHttpServletRequest request) {
MultipartFile multipartFile = request.getFiles("file");
try (InputStream inputStream = multipartFile.getInputStream()) {
//logic ...
}
}
正如我从日志中看到的,请求甚至不调用服务器端点并且在从 UI 端发送数据时失败。好像是网络问题?
另一个奇怪的事情是,这种错误是随机发生的。仅适用于约 2-4% 的用户请求。即使有上传问题的用户尝试再上传几次,通常也可以正常工作
感谢您的任何回答!
【问题讨论】:
-
网络故障?
标签: java spring sockets spring-boot tomcat