Skip to content

Instantly share code, notes, and snippets.

@ciaranarcher
Created July 4, 2011 12:33
Show Gist options
  • Save ciaranarcher/1063287 to your computer and use it in GitHub Desktop.
Save ciaranarcher/1063287 to your computer and use it in GitHub Desktop.
ColdFusion Timeout Experiment
<cfcomponent output="false">
<cfset this.name = "testApp" />
<cfset this.clientManagement = false />
<cfset this.sessionManagement = false />
<cffunction name="onError" access="public" returntype="void" output="false" hint="">
<cfargument name="err" type="any" required="true" />
<cflog log="application" type="error" text="onError() called in '#this.name#' application: #ARGUMENTS.err.message#" />
</cffunction>
</cfcomponent>
<!---
****************************************************************************************
Set a two second max request time for this page - ensure that in CF admin you have the
Timeout Requests after (x seconds) setting ticked! Otherwise NO timeout values will be
checked!
****************************************************************************************
--->
<!--- --->
<cfsetting requesttimeout="2" />
<!--- Get a timer --->
<cfset x = getTickCount() />
<cfloop from="1" to="5" index="i">
<cfset sleep(1000) /> <!--- Sleep the request thread for a second --->
<cfoutput><p>Ran for #getTickCount() - x# ms...</p></cfoutput>
<!--- Making a cfhttp call will result in the timeout value being checked, which in this case will cause an exception --->
<cfhttp url="http://google.com" />
</cfloop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment