大佬们,帮忙看看 java.io.EOFException: Unexpected EOF read on the socket

在提交base64比较大的参数时,报:Unexpected EOF 错误,springboot版本2.3.2,约有5%的概率报错,部分错误信息如下:

Caused by: org.apache.catalina.connector.ClientAbortException: java.io.EOFException: Unexpected EOF read on the socket
	at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:340)
	at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuffer.java:632)
	at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:362)
	at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:132)
	at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:110)
	at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1719)
	at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1696)
	at org.apache.commons.io.IOUtils.copy(IOUtils.java:1671)
	at com.netflix.zuul.http.HttpServletRequestWrapper.parseRequest(HttpServletRequestWrapper.java:152)
	at com.netflix.zuul.http.HttpServletRequestWrapper.getParameter(HttpServletRequestWrapper.java:301)
	... 74 common frames omitted


Caused by: java.lang.IllegalStateException: Cannot parse the request!
	at com.netflix.zuul.http.HttpServletRequestWrapper.getParameterMap(HttpServletRequestWrapper.java:324)
	at org.springframework.web.servlet.DispatcherServlet.lambda$logRequest$2(DispatcherServlet.java:964)
	at org.springframework.core.log.LogFormatUtils.traceDebug(LogFormatUtils.java:86)
	at org.springframework.web.servlet.DispatcherServlet.logRequest(DispatcherServlet.java:956)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:911)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	... 96 common frames omitted

java.io.EOFExceptio 这是流读完了异常。F12看一看客户端,是不是在哪里异常了。导致上传被中断。

感谢回复,是参数太大了,上传时间太长,客户端超时断开链接,服务端还在读,导致读取异常。

1 Like

对于大文件上传,转换为bse64后其实效率更低。不如直接上传二进制文件。

也是哈,考虑欠周到