Handling Timeout Requests

Word Count: 178

As explained in the ColdFusion Administrator the Request Timeout property allows us to terminate requests that take longer than the specified time. This prevents unusually long requests from occupying server resources and impairing the performance of other requests. There are two ways to control this time. The first and easiest is to set a global time for your server in the administrator. When logged in click on the settings button under Server Settings. From there locate the timeout request and change it to a value of your choice. The attribute is a number and represents seconds. If you are on shared host that this is not an option for you. Lucky for you there is a way to change this programatically. You can use the cfsetting tag and use the requestTimeout attribute. From the livedocs we can see this takes precedence over the the administrator timeout. You could set this in your application component for your entire system or you can use on a per template basis.

<cfsetting requesttimeout="120">


Comments

#1 Posted By: Ben Nadel Posted On: 2/20/07 8:04 AM
Dan, I have a question about handling time out errors that maybe you can help me with. Apparently, there are two different time outs: page time outs and query time outs ; these operate under different settings (as far as I know). The problem I run into occasionally is that a query will execute for longer than the page timeout (as a page will not time out while a query is still running... I THINK) but then, once the query stops running, the page times out immediately aftewards and this timeout seems to stop even the onError event method from being fired.

I am not sure if I am explaining that well, but essentially what seems to be happening is that the page times out in a such a way that not even the error handler (onError application even method) has time to be run. Does this sound crazy? How can I handle this? Does the execution time of the page carry over to the onError event method?
#2 Posted By: Dan Posted On: 2/20/07 10:56 AM |
Author Comment
Ben,
I am not sure that there are two different timeout settings. Have you tried bumping out the requestTimeout for that specfic template to something just to see if the template executes?
#3 Posted By: Ben Nadel Posted On: 2/20/07 3:30 PM
Hey Dan,

Can you take a look at this, I would love some feedback:

http://www.bennadel.com/index.cfm?dax=blog:540.vie...

While this does not involve a CFQuery tag, this partially demonstrates what I was talking about. The OnError() event simply cannot handle the request time out error. Other than pumping up the request time out, I cannot think of a better way to handle this. And, upping the time out is not always the solution I can have - think about a page where I want to enforce the time out AND do some logging. I cannot figure this one out :(
#4 Posted By: Dan Posted On: 2/20/07 3:41 PM |
Author Comment
Ben,
Why not wrap the cfquery code in a try / catch block. You can then look for that specific error or any for that matter and handle it accordingly. Just a thought!


Post Your Comment

Leave this field empty







Show Captcha

If you subscribe, any new posts to this thread will be sent to your email address.

Copyright © 2007 Dan Vega | BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.