CFTHREAD CFHTTP timeout
Basically I have a job scheduling engine that executes cfhttp calls from within a cfthread tag. This is so multiple jobs can run concurrently. Basically what I want to be able to do is extend the timeout period beyond what the administrator's default is on some of my cfhttp calls so that I can let them finish and get the results from the page I'm calling. But that's not happening.
My CF Admin Request Timeout setting is 30 seconds. I have two files. The first is called 'MyThreadedCFHTTP.cfm':
<cfthread action="run" name="job_#CreateUUID()#">
<cfsetting requesttimeout="400" >
<cflog text="Web Service Request: Starting" file="JobSchedulerTest" >
<!--- Lets do our cfhttp call --->
<cfset var httpResults = ""/>
<cfhttp method="get" url="http://localhost:8500/sessiontesting/CFHTTPRequestTimeOut/GetResults.cfm?RequestTime=400" result="httpResults" timeout="400">
<cflog text="Web Service Result: #httpResults.FileContent#" file="JobSchedulerTest" >
</cfthread>**strong text**
My cfm file that is called is 'GetResults.cfm'. It just sleeps for 59 seconds before doing anything.
<cfsetting requesttimeout="400"/>
<cfset sleep(59000)/>
This doesn't work as expected. The cfhttp call, though it has has timeout of 400 seconds and I have a cfsetting/requesttimeout value right before it, will abort after 30 seconds with a Connection Timeout message. This is the servers default setting. Now whats interesting is if you remove the tags, the call will finish successfully.
I'm assuming this has something to do when the cfhttp call is threaded its executing within some completely new context and so it can only see the administrator's request timeout value. But I'm just guessing.
Can someone help me figure a solution here. I could remove the timeout value from the administrator, but I really hate to have to do that as I could would much prefer to keep that and only override it when I explicitly say so.
I do not have any personal experience with this but after some searching it seems that the <cfsetting requesttimeout="">
code is not honored by the <cfthread>
tag. See the following references that I found.
Note that I am not suggesting you make the changes that they detail like disabling the request timeout setting in the ColdFusion administrator. I don't think that is a good idea. I am just passing along this information that I found. The gist being that the <cfthread>
tag does not support the <cfsetting requesttimeout="">
option. So you probably need to find another way to do what you need or optimize your code to finish before the set timeout.
cfthread and request timeout in coldfusion
In the process I found the following after some testing and playing around:
Increase request timeout for a thread in CFML
As you can see, I've tried adding a <cfsetting requestTimeout=240 />
to the top of the thread to try and make it live longer... no dice.
Am I utilizing <cfthread> correctly for this solution?
As for thread timeouts - you can specify a max time to wait for threads you created to rejoin page execution, but AFAIK there is no way to put a timeout (like a page request timeout) on the thread you created.
And Charlie Arehart has a pretty good article on ColdFusion request timeouts in general - CF911: Lies, Damned Lies, and CF Request Timeouts...What You May Not Realize
链接地址: http://www.djcxy.com/p/31238.html上一篇: 使用cfhttp从bitly url检索页面内容时出错
下一篇: CFTHREAD CFHTTP超时