在spring boot中上传网络连接慢的文件时出错

Posted

技术标签:

【中文标题】在spring boot中上传网络连接慢的文件时出错【英文标题】:Error while uploading file with slow network connection in spring boot 【发布时间】:2020-07-13 07:09:48 【问题描述】:

我们开发了一个可以上传文件的应用程序,它正在运行。 但是当我们尝试在 Chrome 中上传一个 2MB 的文件时,网络连接速度很慢,我们遇到了错误。

这是堆栈跟踪:

ecf-api          | 2020-04-01 13:14:59.311 ERROR 1 --- [io-8080-exec-10] o.a.c.c.C.[.[.[.[dispatcherServlet]      : Servlet.service() for servlet [dispatcherServlet] in context with path [/api] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.impl.IOFileUploadException: Processing of multipart/form-data request failed. java.io.EOFException: Unexpected EOF read on the socket] with root cause
ecf-api          |
ecf-api          | java.io.EOFException: Unexpected EOF read on the socket
ecf-api          |      at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:763)
ecf-api          |      at org.apache.coyote.http11.Http11InputBuffer.access$300(Http11InputBuffer.java:42)
ecf-api          |      at org.apache.coyote.http11.Http11InputBuffer$SocketInputBuffer.doRead(Http11InputBuffer.java:1108)
ecf-api          |      at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:102)
ecf-api          |      at org.apache.coyote.http11.Http11InputBuffer.doRead(Http11InputBuffer.java:249)
ecf-api          |      at org.apache.coyote.Request.doRead(Request.java:551)
ecf-api          |      at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:336)
ecf-api          |      at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuffer.java:632)
ecf-api          |      at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:362)
ecf-api          |      at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:132)
ecf-api          |      at org.apache.tomcat.util.http.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:977)
ecf-api          |      at org.apache.tomcat.util.http.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:881)
ecf-api          |      at java.base/java.io.InputStream.read(InputStream.java:205)
ecf-api          |      at org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:98)
ecf-api          |      at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:293)
ecf-api          |      at org.apache.catalina.connector.Request.parseParts(Request.java:2870)
ecf-api          |      at org.apache.catalina.connector.Request.getParts(Request.java:2772)
ecf-api          |      at org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1098)
ecf-api          |      at javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:359)
ecf-api          |      at javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:359)
ecf-api          |      at javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:359)
ecf-api          |      at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:95)
ecf-api          |      at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:88)
ecf-api          |      at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:87)
ecf-api          |      at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1178)
ecf-api          |      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1012)
ecf-api          |      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
ecf-api          |      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
ecf-api          |      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
ecf-api          |      at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
ecf-api          |      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
ecf-api          |      at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
ecf-api          |      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
ecf-api          |      at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
ecf-api          |      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
ecf-api          |      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at com.company.oidc.security.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:66)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92)
ecf-api          |      at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
ecf-api          |      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
ecf-api          |      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
ecf-api          |      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
ecf-api          |      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
ecf-api          |      at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
ecf-api          |      at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:109)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
ecf-api          |      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
ecf-api          |      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
ecf-api          |      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
ecf-api          |      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
ecf-api          |      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
ecf-api          |      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
ecf-api          |      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
ecf-api          |      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
ecf-api          |      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
ecf-api          |      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
ecf-api          |      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
ecf-api          |      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
ecf-api          |      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1594)
ecf-api          |      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
ecf-api          |      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
ecf-api          |      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
ecf-api          |      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
ecf-api          |      at java.base/java.lang.Thread.run(Thread.java:834)
ecf-api    

-我们尝试了不同的配置:

spring:
  http:
    multipart:
      enabled: false
      max-file-size: -1
      max-request-size: -1
  
    servlet:
      multipart:
        file-size-threshold: 2KB
        max-file-size: -1
        max-request-size: -1
server:
  connection-timeout: -1
  servlet:
    session:
      timeout: -1
  tomcat:
    connection-timeout: -1

我们还将 tomcat 更改为 undertow,但仍然出现相同的错误,并出现以下堆栈跟踪:

ecf-api          | 2020-04-01 12:51:35.004 ERROR 1 --- [ XNIO-1 task-14] io.undertow.request                      : UT005023: Exception handling request to /api/
ecf-api          |
ecf-api          | org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.RuntimeException: java.io.IOException: UT000128: Remote peer closed connection before all data could be read
ecf-api          |      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
ecf-api          |      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
ecf-api          |      at javax.servlet.http.HttpServlet.service(HttpServlet.java:523)
ecf-api          |      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
ecf-api          |      at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
ecf-api          |      at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
ecf-api          |      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
ecf-api          |      at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
ecf-api          |      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
ecf-api          |      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
ecf-api          |      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at com.company.oidc.security.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:66)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92)
ecf-api          |      at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
ecf-api          |      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
ecf-api          |      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
ecf-api          |      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
ecf-api          |      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
ecf-api          |      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
ecf-api          |      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
ecf-api          |      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
ecf-api          |      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
ecf-api          |      at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
ecf-api          |      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
ecf-api          |      at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:109)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
ecf-api          |      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
ecf-api          |      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
ecf-api          |      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
ecf-api          |      at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
ecf-api          |      at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
ecf-api          |      at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
ecf-api          |      at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
ecf-api          |      at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
ecf-api          |      at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
ecf-api          |      at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
ecf-api          |      at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
ecf-api          |      at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
ecf-api          |      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
ecf-api          |      at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
ecf-api          |      at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
ecf-api          |      at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
ecf-api          |      at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
ecf-api          |      at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
ecf-api          |      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
ecf-api          |      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
ecf-api          |      at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)
ecf-api          |      at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
ecf-api          |      at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
ecf-api          |      at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
ecf-api          |      at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
ecf-api          |      at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
ecf-api          |      at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
ecf-api          |      at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
ecf-api          |      at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
ecf-api          |      at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
ecf-api          |      at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
ecf-api          |      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
ecf-api          |      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
ecf-api          |      at java.base/java.lang.Thread.run(Thread.java:834)
ecf-ap

【问题讨论】:

【参考方案1】:

我们试图专注于 apache 服务器而不是 api。 而且我们发现我们不得不增加请求读取超时时间。 我们将 RequestReadTimeout 设置如下:

RequestReadTimeout body=20,MinRate=1000

这取决于您的需求。欲了解更多信息,请尝试此链接https://httpd.apache.org/docs/2.4/en/mod/mod_reqtimeout.html

【讨论】:

以上是关于在spring boot中上传网络连接慢的文件时出错的主要内容,如果未能解决你的问题,请参考以下文章

Spring Boot怎么处理上传文件时出现的MultipartException

Spring Boot怎么处理上传文件时出现的MultipartException

Spring Boot启动速度慢的原因总结

Spring Boot做文件上传时出现了The field file exceeds its maximum permitted size of 1048576 bytes.错误

设置 SSL 连接时出现 Spring Boot 错误

Spring Boot Redis 使用 Redis 时出现连接被拒绝异常