cfhttp connection timeout - best way to loop or re-try?
Hi, I have a cfhttp call in a cfc that from time to time receives a connection timeout. I'd like to just retry the call again, but not sure of best way to start the call over. I actually don't want to start the whole thing over, just re-try the cfhttp call if it receives a connection timeout. Maybe a cfloop 2 or 3 times? But I don't want it to loop right away, only if it received a timeout. Thoughts? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339357 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: cfhttp connection timeout - best way to loop or re-try?
Maybe you could do something like this: cfhttp url=somURL method=GET result=results cfif findNoCase(200, results.StatusCode) continue to process cfelse re-process /cfif If you get a timeout, I believe the status code will not be 200 and therefore you could try again. HTH... Che -Original Message- From: Casey Dougall [mailto:ca...@uberwebsitesolutions.com] Sent: Thursday, November 18, 2010 1:39 PM To: cf-talk Subject: cfhttp connection timeout - best way to loop or re-try? Hi, I have a cfhttp call in a cfc that from time to time receives a connection timeout. I'd like to just retry the call again, but not sure of best way to start the call over. I actually don't want to start the whole thing over, just re-try the cfhttp call if it receives a connection timeout. Maybe a cfloop 2 or 3 times? But I don't want it to loop right away, only if it received a timeout. Thoughts? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339358 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: cfhttp connection timeout - best way to loop or re-try?
Something like... cfset success = cfset attempts = 0 cfloop condition=success is not 1 and attempts lt 4 cfset attempts = attempts + 1 cftry cfhttp ... timeout=60 ... cfset success = 1 cfcatch cfset success = 0 /cfcatch /cftry /cfloop On Thu, Nov 18, 2010 at 12:38 PM, Casey Dougall ca...@uberwebsitesolutions.com wrote: Hi, I have a cfhttp call in a cfc that from time to time receives a connection timeout. I'd like to just retry the call again, but not sure of best way to start the call over. I actually don't want to start the whole thing over, just re-try the cfhttp call if it receives a connection timeout. Maybe a cfloop 2 or 3 times? But I don't want it to loop right away, only if it received a timeout. Thoughts? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339359 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: cfhttp connection timeout - best way to loop or re-try?
On Thu, Nov 18, 2010 at 1:47 PM, John M Bliss bliss.j...@gmail.com wrote: fset success = cfset attempts = 0 cfloop condition=success is not 1 and attempts lt 4 cfset attempts = attempts + 1 cftry cfhttp ... timeout=60 ... cfset success = 1 cfcatch cfset success = 0 /cfcatch /cftry Thanks guys, just wanted to be sure I was thinking along the same lines here. John, like your example, I'll play around with that. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339360 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm