Welcome to my Tomcat tutorials website!

domenica 13 aprile 2014

tomcat connectiontimeout configuration

Apache tomcat contains a connectionTimeout parameter which defines the amount of time Tomcat will wait for three things:

  • The total amount of time it takes to receive an HTTP GET request.
  • The total amount of time between receipt of TCP packets on a POST or PUT request.
  • The total amount of time between ACKs on transmissions of TCP packets in responses.

Changing the connectionTimeout

In some cases it might be necessary to increase it especially if the response takes too much to be completed on the server, leaving the connection without a response. To increase the connection timeout on tomcat server follow the following steps :

1. Open the file server.xml residing in TOMCAT_HOME/conf/.
2. Set the variable connectionTimeout in it to Value in Milliseconds.(i.e 1000 milliseconds = 1 second)

For example :

If connectionTimeout is not defined, the default value is 60000 (i.e. 60 seconds); however the standard server.xml that ships with Tomcat sets this to 20000 (i.e. 20 seconds).
You can use a value of -1 to indicate no (i.e. infinite) timeout.

Do not set this value to extreme values to avoid hanging your server threads for too much. On the other hand setting it to a value too low, might cause rejecting some of your requests,

1 commento: