Opened 17 years ago

Closed 17 years ago

#454 closed defect (fixed)

File upload times out

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
Priority: major Milestone: BASE 2.1.2
Component: web Version: 2.1
Keywords: Cc:


The file upload may randomly get a timeout exception: on page /base21/filemanager/upload/progress.jsp
Version     BASE 2.1.1pre (build #0; schema #20)
Web server     Apache Tomcat/5.5.20
Database Dialect     org.hibernate.dialect.MySQLInnoDBDialect
JDBC Driver     com.mysql.jdbc.Driver (version 3.1)
Java runtime     Java(TM) 2 Runtime Environment, Standard Edition (1.5.0_06-b05), Sun Microsystems Inc.
Operating system     Linux i386 2.6.5-7.276-default
Memory     Total: 60.3 MB
Free: 11.6 MB
Max: 494.5 MB
Browser     Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
Error message     Read timed out
Stack trace Method) org.apache.coyote.http11.InternalInputBuffer.fill( org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead( org.apache.coyote.http11.filters.IdentityInputFilter.doRead( org.apache.coyote.http11.InternalInputBuffer.doRead( org.apache.coyote.Request.doRead( org.apache.catalina.connector.InputBuffer.realReadBytes( org.apache.tomcat.util.buf.ByteChunk.substract( org.apache.catalina.connector.InputBuffer.readByte( javax.servlet.ServletInputStream.readLine( org.apache.catalina.connector.CoyoteInputStream.readLine( net.sf.basedb.clients.web.fileupload.FileUpload$UploadStream.readMoreData( net.sf.basedb.clients.web.fileupload.FileUpload$ net.sf.basedb.util.FileUtil.copy( org.apache.jsp.filemanager.upload.upload_jsp._jspService( org.apache.jasper.runtime.HttpJspBase.service( javax.servlet.http.HttpServlet.service( org.apache.jasper.servlet.JspServletWrapper.service( org.apache.jasper.servlet.JspServlet.serviceJspFile( org.apache.jasper.servlet.JspServlet.service( javax.servlet.http.HttpServlet.service( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( net.sf.basedb.clients.web.servlet.CharacterEncodingFilter.doFilter( org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( org.apache.catalina.core.ApplicationFilterChain.doFilter( org.apache.catalina.core.StandardWrapperValve.invoke( org.apache.catalina.core.StandardContextValve.invoke( org.apache.catalina.core.StandardHostValve.invoke( org.apache.catalina.valves.ErrorReportValve.invoke( org.apache.catalina.core.StandardEngineValve.invoke( org.apache.catalina.connector.CoyoteAdapter.service( org.apache.coyote.http11.Http11Processor.process( org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection( org.apache.tomcat.util.threads.ThreadPool$

  • It appears to happen at random times. Sometimes it works, sometimes not.
  • It seems to be related to slower network connections. We have never been able to reproduce the error locally.
  • We have only seen this error when the client machine is a windows box.
  • It has happened both with IE6, IE7 and Firefox
  • We have only seen it on the 2.1.x versions, not in the trunk so far

What we can try:

  • First, we must be able to reproduce this error locally
  • Check if it has something to do with the character encoding filter servlet. If it does we should replace the file upload with a real servlet instead of a JSP page
  • Check if it has something to do with the session=false attribute that is present in the trunk but not in the 2.1.x branch
  • Check if has something to do with the reload of the progress bar

Change History (5)

comment:1 by Nicklas Nordborg, 17 years ago

I have testet this from my home which has a very slow connection. None of the ideas mentioned above made any difference. Searching on the net finds some other user with similiar problems but almost none with any solutions. One advice was found on After setting disableUploadTimeout="false" in my server.xml in TOMCAT_HOME/conf I have not been able to reproduce the error. I could upload at least twice as many files as before without getting any error.

comment:2 by Nicklas Nordborg, 17 years ago

Status: newassigned

I have now investigated this a bit more by delving in the Tomcat code and I think I have a possible solution. This is what I found:

  • Tomcat has two different timeouts. One timeout for parsing the headers of the request and another timeout for the rest of the POST:ed data

  • The header-timeout is initially the timeout specified in server.xml as the connectionTimeout attribute for the connector tag. This timeout is normally 20000ms.

  • Depending on the number of threads that Tomcat thinks are active the header-timeout can be decreased by as much as a factor of 20 or more. This may decrease the header-timeout to less than a second.

  • When disableUploadTimeout="true" is specified no timeout is set for the data part. The timeout is left to the same used for parsing the headers. This seems to me like a bug in Tomcat.

  • When disableUploadTimeout="false" is specified the timeout is set to the unmodified connectionTimeout value.

I think this explains most of the problems we have had:

  • It doesn't happen locally since there is very little probablity that one has to wait 1 second for the next data-package to arrive.

  • It doesn't happen if the "Max upload" setting is decrease in BASE since then there will always be an incoming packet on queue.

  • The problem only happens randomly and works the first couple of times because Tomcat doesn't start modifying the timeout until it thinks it is busy.

  • Setting disableUploadTimeout="false" beacuse even with a slow connection we never have to wait 20 seconds.

I now also have a possible solution. The SocketTimeoutException only tells us that no data was read during the time we waited. The connection is still open and usable and we can simply try reading data one more time (or as many times as we think is needed).

comment:3 by Nicklas Nordborg, 17 years ago

(In [3003]) References #454: File upload times out

Possible fix but have to be tested with slow connection.

comment:4 by Nicklas Nordborg, 17 years ago

(In [3010]) References #454: File upload times out

Use Ajax for updating the progress bar if the browser supports it.

comment:5 by Jari Häkkinen, 17 years ago

Resolution: fixed
Status: assignedclosed

The fix is now working on my slow connection test machines.

Note: See TracTickets for help on using tickets.