5

I am facing this issue on a daily basis. I am having an application which Catches the huge data from various applications in the nightly schedule jobs through a cfhhtp call/request. The problem here is that it calls the 'extensive list of scopes' to catch the data, and unfortunately we cannot limit the scopes :( The timeout set in the Task is 9000 seconds(which already is quite high), but still it says timeout at cfhttp tag

"The request has exceeded the allowable time limit Tag: cfhttp".

I don't know how cfhttp works, but there should be some solution that if it catches data for some long time and from various scopes, it should not throw error and continues to work till the last request.

<cfset dynVarName = "funded" & bizforShort>
<cfif structKeyExists(variables,dynVarName)>
    <cfset howManyCustomScopes = listLen(structkeylist(variables[dynVarName],"|" ),"|" )>
    <cfmodule template="#Request.Library.CustomTags.VirtualPath#Scheduler_LogDetail.cfm"
                  Step="Funded Level Cache" Detail="Custom Scopes to be cached: #howManyCustomScopes#"
                  LogData=""></cfmodule>
    <cfloop collection="#variables[dynVarName]#" item="t">
        <cfset tempurl = variables[dynVarName][t]["url"]>
        <cfset tempurl = tempurl & "&retainCache=1">
        <cfoutput>
            <cfhttp url="#tempurl#" method="GET" resolveurl="false" timeout="9000">
            #tempurl#<br>
            <cfset scopesCachedCounter = scopesCachedCounter + 1>
            <cfmodule template="#Request.Library.CustomTags.VirtualPath#Scheduler_LogDetail.cfm" Step="Funded Scopes Cache" Detail="#scopesCachedCounter#.- #t#" LogData="#tempurl#"></cfmodule>
        </cfoutput>
    </cfloop>
</cfif>

Not: The page has one 'include' from where it catches the scope.

user3071284
  • 6,955
  • 6
  • 43
  • 57
Vasu
  • 319
  • 5
  • 19
  • What is the timeout set in the server settings ? – Dungeon Hunter Mar 19 '14 at 09:27
  • @dungeonHunter got there a little before me, but `cfhttp` will use the lesser of the timeout values in the server admin and the `cfhttp` tag. – Jarede Mar 19 '14 at 09:28
  • server setting has 9000 seconds timeout set – Vasu Mar 19 '14 at 09:29
  • you mean, if server setting has 3000 seconds timeout set and cfhttp tag has 9000 seconds, so it will pic lesser value as 3000secs? – Vasu Mar 19 '14 at 09:31
  • 1
    yep that's right @Vasu – Jarede Mar 19 '14 at 09:35
  • But it has 9000 already set. Couldn't figure out how to improve the performance of cfhttp call... Considering the huge data and extensive scopes the performance of cfhttp should be at higher level – Vasu Mar 19 '14 at 09:39
  • I might be utterly wrong, so someone with more experience might need to set me straight: you're looping doing x requests that take 9000 seconds each, your admin is set at a timeout of 9000 seconds. Won't it complete the first request and then timeout before it gets to the second request (in the loop) as 9000 seconds has already passed. At which point it might be better to thread this if the ordering doesn't make a difference? – Jarede Mar 19 '14 at 09:51
  • even i am not sure how this cfhttp makes a request. But in this case, cfhttp looping over a collection of scopes. As i said there are huge number of scopes to fetch data from, it times out in between. Can we use to work this out? – Vasu Mar 19 '14 at 09:57
  • you can use threading if ordering doesn't matter. So if loop 2 doesn't rely on the processing of loop 1 already being completed you're good to go as you might find thread 14 comes back before thread 3. Again though, i might be wrong in what I have said about the blocking. – Jarede Mar 19 '14 at 10:00
  • Yes, ordering doesn't matter here. I just want that all the catching should be completed without any timeout error. So if suppose i want to use threading, so what i need to do is just wrap a around call, right? like this below? #tempurl#
    I am new to this cfhttp case, so any help would be appreciated.
    – Vasu Mar 19 '14 at 10:08
  • Not related to your question but there is a weakness in your approach. If an error occurs anywhere, the entire job will stop and you might not know at what point it stopped. I suggest that you add try/catch and logging inside your loop. – Dan Bracuk Mar 19 '14 at 12:24
  • Something else to look at is the content of the all those files you are processing. If any of them has code to set a shorter timeout, that might override your 9000 seconds. That happened to us, but we were using cfinclude, not cfhttp. – Dan Bracuk Mar 19 '14 at 13:57
  • Thanx for the comments Dan. But adding try/catch will just catch the exception. The thing is I want my page should process successfully no matter for how long it may run. – Vasu Mar 20 '14 at 06:18

1 Answers1

3

At the top of the page, add the following cfsetting code, assigning a large enough value to requestTimeOut. This definitively sets the time out for the entire page, allowing any tags to take as long as they need as long as their cumulative execution time doesn't total more than this value.

<cfsetting requestTimeOut = "9000" />
user3071284
  • 6,955
  • 6
  • 43
  • 57