AnsweredAssumed Answered

[Solved] Very large uploads result in timeout exception

Question asked by hbf on Nov 9, 2007
Here's a solution to an issue I've run into; it might be helpful to others. (I don't think it is restricted to Alfresco PHP but I encountered it in this context.)

For very large files that I uploaded via writeContentFromFile(), I obtained

19:26:45,484 User:admin ERROR [[localhost].[/alfresco].[uploadContent]] Servlet.service() for servlet uploadContent threw exception
org.alfresco.service.cmr.repository.ContentIOException: Failed to copy content from input stream:
   writer: ContentAccessor[ contentUrl=store://2007/11/9/19/25/17f90318-8ef1-11dc-a01d-aff93af5d73b.bin, mimetype=application/pdf, size=0, encoding=UTF-8, locale=en_US]
        at org.alfresco.repo.content.AbstractContentWriter.putContent(AbstractContentWriter.java:428)
        at org.alfresco.web.app.servlet.UploadContentServlet.doPut(UploadContentServlet.java:243)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
        at java.lang.Thread.run(Thread.java:613)
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:748)
        at org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:778)
        at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:116)
        at org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffer.java:713)
        at org.apache.coyote.Request.doRead(Request.java:419)
        at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:265)
        at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:403)
        at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:280)
        at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:162)
        at org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:117)
        at org.alfresco.repo.content.AbstractContentWriter.putContent(AbstractContentWriter.java:423)
        … 17 more

A workaround consists in setting "connectionTimeout" to a very large number in tomcat/conf/server.xml:

    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="500000" disableUploadTimeout="true" />

Best,
Kaspar

Outcomes