Search code examples
javaclojurejetty

What causes a jetty idletimeout


Our server is using clojure ring.adapter.jetty and one of our users is causing a java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 200000/200000 ms error when uploading a large(ish) file, ~20MB. He has a very slow connection, but I dont get the same error throttling my connection. The timeout exception is high enough (this is the idle timeout, not upload timeout)

The quick version of our upload process is using a multi-part form, and then copying the temp file to the server folder with java.io.copy.

I am trying to at minimum re-create the error with my machine to get error handling working. If I find any solutions that change my application code, I need to test them as well by trying to cause the error. So far I tried throttle my speed to as close to 0 as it will allow, and setting a super high latency in devtools (chrome), and set the jetty timeouts to 100ms but it still uploads fine.

Is there also anything the user can do to help reduce the chance of a timeout.


Solution

  • The IdleTimeout triggers when there is no activity on the connection, Read or Write for the configured IdleTimeout.

    In your user's case there was no activity on that Connection for 200,000 ms (about 3.3 minutes) and the connection was shut down.

    3.3 minutes is a actually a low value for mobile networks.

    Based on experience, you likely want to increase it to 300,000 ms (or 5 minutes) at a minimum.