Spring Boot v1.4 - 处理multipart / form-data请求失败。 null] with root cause java.net.SocketTimeoutException:null

时间:2017-06-08 06:35:19

标签: spring-boot tcp multipartform-data spring-websocket

我有1000多个物联网设备以小文件(约1 Kb)的形式不断向我的Spring-Boot应用服务器发送数据。

我会在特定的时间间隔内收到此错误。有人可以指出出了什么问题吗?

我有控制器上传文件以及 TCP套接字

ERROR 37762 --- [io-8080-exec-29] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not 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. null] with root cause

java.net.SocketTimeoutException: null
    at org.apache.tomcat.util.net.NioBlockingSelector.read(NioBlockingSelector.java:201)
    at org.apache.tomcat.util.net.NioSelectorPool.read(NioSelectorPool.java:235)
    at org.apache.tomcat.util.net.NioSelectorPool.read(NioSelectorPool.java:216)
    at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1212)
    at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1163)
    at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:742)
    at org.apache.coyote.http11.Http11InputBuffer.access$400(Http11InputBuffer.java:38)
    at org.apache.coyote.http11.Http11InputBuffer$SocketInputBuffer.doRead(Http11InputBuffer.java:1073)
    at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:100)
    at org.apache.coyote.http11.Http11InputBuffer.doRead(Http11InputBuffer.java:303)
    at org.apache.coyote.Request.doRead(Request.java:511)
    at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:318)
    at org.apache.tomcat.util.buf.ByteChunk.checkEof(ByteChunk.java:397)
    at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:379)
    at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:338)
    at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:189)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:132)
    at org.apache.tomcat.util.http.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:946)
    at org.apache.tomcat.util.http.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:850)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:132)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:98)
    at org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:68)
    at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:293)
    at org.apache.catalina.connector.Request.parseParts(Request.java:2792)
    at org.apache.catalina.connector.Request.parseParameters(Request.java:3167)
    at org.apache.catalina.connector.Request.getParameter(Request.java:1109)
    at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

1 个答案:

答案 0 :(得分:0)

防火墙可能会丢弃长时间处于非活动状态的TCP连接。解决方案是send TCP keepalives

还检查通过防火墙的最大连接数以及未超过最大OS文件描述符数。