是什么导致引发SocketTimeoutException

时间:2013-09-25 13:53:07

标签: servlets

我的要求是记录用户语音并将其保存在服务器上(同时多个用户)。代码是:

            in = (InputStream) request.getInputStream();                         
            fos = new FileOutputStream(f1);
            int read = 0;
            while ((read = in.read()) != -1) {
                fos.write(read);
            }
            fos.close();
            in.close();

我在尝试一次为多个用户录制语音时遇到以下异常。对于单个用户,这不会给我任何例外。

java.net.SocketTimeoutException     在org.apache.coyote.http11.InternalAprInputBuffer.fill(InternalAprInputBuffer.java:796)     at org.apache.coyote.http11.InternalAprInputBuffer $ SocketInputBuffer.doRead(InternalAprInputBuffer.java:830)     at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:116)     在org.apache.coyote.http11.InternalAprInputBuffer.doRead(InternalAprInputBuffer.java:738)     在org.apache.coyote.Request.doRead(Request.java:427)     在org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:304)     在org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:386)     在org.apache.catalina.connector.InputBuffer.readByte(InputBuffer.java:317)     在org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:105)     在CommonPackage.Upload.processRequest(Upload.java:78)     在CommonPackage.Upload.doPost(Upload.java:115)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:710)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:803)     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)     在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)     在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)     在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)     在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)     在org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)     在org.apache.coyote.http11.Http11AprProtocol $ Http11ConnectionHandler.process(Http11AprProtocol.java:594)     在org.apache.tomcat.util.net.AprEndpoint $ Worker.run(AprEndpoint.java:1675)     在java.lang.Thread.run(Thread.java:619)

谢谢

1 个答案:

答案 0 :(得分:1)

您很可能会遇到此异常,因为您尝试从请求中读取数据但超过了默认超时值。

在tomcat中,默认值为60秒。请参阅以下指南,了解如何调整连接器的连接超时:http://tomcat.apache.org/tomcat-7.0-doc/config/http.html