You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Elankath, Tarun (Cognizant)" <ET...@blr.cognizant.com> on 2003/11/12 14:27:05 UTC

Tomcat Settings advice on long-running process.

Hi list,

We have a long running process (all in java, not external) that is initiated from struts action class, (does a lot of file I/O, etc)

The browser apparently timesout after about 20 minutes or whereabouts, and then suddenly the process do stops bang in the middle as soon as this happens. This is quite puzzling as one expects the process to continue even if the browser timed out.

I do know the correct solution is to make it run in the background and give constant updates to the user, however, we just need to make it work ASAP with the correct approach. We'll migrate to the background process & progress page approach soon enough.

Any pointers/comments on browser (Internet Explorer), server (Tomcat) settings and Struts settings to handle long-running activities in the web-request cycle would be greatly appreciated. I did scout the web, but apart from the connectionTimeout setting in the <connector> element of tomcat, I didn't find anything much. I don't think increasing session-timeout would be of any help here.

Any pointers on how to avoid the 'freeze' would also be much appreciated. 

Thank you,
Tarun

Re: Tomcat Settings advice on long-running process.

Posted by Tim Funk <fu...@joedog.org>.
During the middle of processing, the browser drops the socket. This casues 
the next write by tomcat to fail with a Socket exception (Actually 
ClientAbort or similar).

One workaround is to put the long running operation in its own thread 
(carefully) and have the thread update a "status" object which lives in a 
session. (Or static singleton if your feeling lucky/brave).

Then the browser displays the contents of the "status" object and has a META 
refresh every {insert here} seconds. If the long running process did its 
thing, your can then display the alternate results/download file/whatever.

-Tim

Elankath, Tarun (Cognizant) wrote:

> Hi list,
> 
> We have a long running process (all in java, not external) that is initiated from struts action class, (does a lot of file I/O, etc)
> 
> The browser apparently timesout after about 20 minutes or whereabouts, and then suddenly the process do stops bang in the middle as soon as this happens. This is quite puzzling as one expects the process to continue even if the browser timed out.
> 
> I do know the correct solution is to make it run in the background and give constant updates to the user, however, we just need to make it work ASAP with the correct approach. We'll migrate to the background process & progress page approach soon enough.
> 
> Any pointers/comments on browser (Internet Explorer), server (Tomcat) settings and Struts settings to handle long-running activities in the web-request cycle would be greatly appreciated. I did scout the web, but apart from the connectionTimeout setting in the <connector> element of tomcat, I didn't find anything much. I don't think increasing session-timeout would be of any help here.
> 
> Any pointers on how to avoid the 'freeze' would also be much appreciated. 
> 
> Thank you,
> Tarun
> 
> 
> ------------------------------------------------------------------------
> 
> 
> This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
> If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. 
> Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly 
> prohibited and may be unlawful.
> 
> 		Visit us at http://www.cognizant.com
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Tomcat Settings advice on long-running process.

Posted by Rodrigo Ruiz <rr...@gridsystems.com>.
Elankath, Tarun (Cognizant) wrote:

>Hi list,
>
>We have a long running process (all in java, not external) that is initiated from struts action class, (does a lot of file I/O, etc)
>
>The browser apparently timesout after about 20 minutes or whereabouts, and then suddenly the process do stops bang in the middle as soon as this happens. This is quite puzzling as one expects the process to continue even if the browser timed out.
>  
>
If you do not write anything to the servlet output, perhaps Tomcat is 
assuming some kind of connection timeout or it is somehow detecting that 
the remote browser has broken the connection. I guess you cannot change 
this behaviour.

>I do know the correct solution is to make it run in the background and give constant updates to the user, however, we just need to make it work ASAP with the correct approach. We'll migrate to the background process & progress page approach soon enough.
>  
>
That's correct. IMHO you should move to this approach ASAP. Otherwise, 
you could encounter migration problems and bugs, due to some differences 
in how to make thing work. Remember your thread will have to notify 
state changes to a listener, or publish state data for your structs 
action to be able to get it. You should take this into account right 
now, even before migration :-)

>Any pointers/comments on browser (Internet Explorer), server (Tomcat) settings and Struts settings to handle long-running activities in the web-request cycle would be greatly appreciated. I did scout the web, but apart from the connectionTimeout setting in the <connector> element of tomcat, I didn't find anything much. I don't think increasing session-timeout would be of any help here.
>  
>
If you have access to the servlet output from your process, you could 
write something to it from time to time. If, for example, you write 
"<html>" right at the beggining of your servlet process, you can write 
dummy comments like "<!-- -->". If you put these statements in the right 
point, you could keep the connection alive until the process finishes. 
If you do this, remember to do an out.flush() after the writing.

I once did something similar. I wrote an html page with two divs 
simulating a progress bar. My process started just before writing the 
</html> tag. During the process I was sending a javascript code that was 
updating the inner div width according to the current state of the process.

This worked for me, but it made my process code far more complex than 
necessary... and than maintainable :-P

Finally, I dropped that code and replaced it by a background thread 
approach.

Hope this helps you,
Rodrigo Ruiz

>Any pointers on how to avoid the 'freeze' would also be much appreciated. 
>
>Thank you,
>Tarun
>  
>
>------------------------------------------------------------------------
>
>
>This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
>If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. 
>Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly 
>prohibited and may be unlawful.
>
>		Visit us at http://www.cognizant.com
>
>
>  
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org