从inputstream读取数据时出现sockettimeout异常
源代码public void clientData(HttpServletRequest request, HttpServletResponse response){
InputStream in = request.getInputStream();
String body = null;
body = IOUtils.toString(in);
}
org.apache.catalina.connector.ClientAbortException: java.net.SocketTimeoutException|
at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:348)|
at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuffer.java:663)|
at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:370)|
at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:183)|
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)|
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)|
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)|
at java.io.InputStreamReader.read(InputStreamReader.java:184)|
at java.io.Reader.read(Reader.java:140)|
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1680)|
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1659)|
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1636)|
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1583)|
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1608)|
at org.apache.commons.io.IOUtils.toString(IOUtils.java:668)|
at org.apache.commons.io.IOUtils.toString(IOUtils.java:646)|
Caused by: java.net.SocketTimeoutException|
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:1282)|
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1225)|
at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:737)|
at org.apache.coyote.http11.Http11InputBuffer.access$300(Http11InputBuffer.java:42)|
at org.apache.coyote.http11.Http11InputBuffer$SocketInputBuffer.doRead(Http11InputBuffer.java:1120)|
at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:140)|
at org.apache.coyote.http11.Http11InputBuffer.doRead(Http11InputBuffer.java:262)|
at org.apache.coyote.Request.doRead(Request.java:581)|
at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:344)|
... 59 more|
server.xml具有以下配置
connectionTimeout ="20000";maxThread ="150">
有数千个客户端并发访问tomcat服务器
注意:无法重现上述情况,有时会出现此异常
server.xml中达到20秒(connectionTimeout)后发生异常
发现一个问题,问题是由于客户端和服务器之间的带宽。当我们减少客户端和服务器之间的流量(请求数据大小减少)
运行正常