Increasing the connection timeout between browser and the tomcat server
There is a case stuck recently in my Grails development project where I need to increase the connection timeout between the browser and the server, because of the reason before the response get completed server leave the connection which resulted in no response. My colleague Himanshu told me to change the setting in server.xml, which help in my purpose.
To increase the connection timeout on tomcat server follow the below steps:
1. Open the file server.xml residing in tomcat6/conf/.
2. You just need to set variable connectionTimeout in it to Value in Milliseconds.(i.e 1000 milliseconds = 1 second)
For example:
File: server.xml
[java]
[/java]
I thought it will be useful to share, hope it helps.
Thanks Matthias for your valuable comment. Yes you are absolutely right, about async solution and i had already implemented that 😉
Before there was a issue and i need to fix it in short amount of time, without deployment.. so i made changes to the tomcat setting and restarted it. 😉 for time being to handle the functionality to generate and download a large file. But later implemented the async solution for it.
Well.. if an application needs 20 seconds to process the request you’re far better of with some async solution and in doing so giving the user immediate response with some banner like “please wait…”. Take a look how it’s done on GitHub or Gitorious when cloning a repository.
The idea is to have some messaging solution in place that receives the request, processes it and in the mean time user is given a page that’ll reload in a few seconds.