0
applicationTimeout
Explorer
,
/t5/coldfusion-discussions/applicationtimeout/td-p/380441
Apr 18, 2008
Apr 18, 2008
Copy link to clipboard
Copied
I always thought that applicationTimeout always restarted
after each page request - at least, this is how it seems to work
using application.cfm.
Now (we just got CF8 here, from CF6MX) I'm trying out application.cfc and finding that it times out exactly at the set time, no matter how much clicking and refreshing I do.
My suspicions were proven when I appended the current minutes to the application name every time it restarted. Every two minutes, the application name would change - confirmed using the debugger.
Now (we just got CF8 here, from CF6MX) I'm trying out application.cfc and finding that it times out exactly at the set time, no matter how much clicking and refreshing I do.
My suspicions were proven when I appended the current minutes to the application name every time it restarted. Every two minutes, the application name would change - confirmed using the debugger.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/applicationtimeout/m-p/380442#M34345
Apr 18, 2008
Apr 18, 2008
Copy link to clipboard
Copied
sk8save wrote:
> I always thought that applicationTimeout always restarted after each page
> request - at least, this is how it seems to work using application.cfm.
That is the way it is supposed to work.
>
> Now (we just got CF8 here, from CF6MX) I'm trying out application.cfc and
> finding that it times out exactly at the set time, no matter how much clicking
> and refreshing I do.
>
Small code examples? It is possible you are not refreshing the
application as you think you are.
It is very contingent on the application 'name' associated with a
template. Different names equals different time outs and no name equals
no application at all.
> I always thought that applicationTimeout always restarted after each page
> request - at least, this is how it seems to work using application.cfm.
That is the way it is supposed to work.
>
> Now (we just got CF8 here, from CF6MX) I'm trying out application.cfc and
> finding that it times out exactly at the set time, no matter how much clicking
> and refreshing I do.
>
Small code examples? It is possible you are not refreshing the
application as you think you are.
It is very contingent on the application 'name' associated with a
template. Different names equals different time outs and no name equals
no application at all.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
sk8save
AUTHOR
Explorer
,
/t5/coldfusion-discussions/applicationtimeout/m-p/380445#M34348
Apr 21, 2008
Apr 21, 2008
Copy link to clipboard
Copied
I've attached my application.cfc
I logged the functions onApplicationStart and onApplicationEnd. Here is a small example of what happens:
[02:35:51] Application AppCFC_35 Started...
[02:36:00] Application AppCFC_36 Started...
This was having a javascript refresh the page every few seconds for not even 30 seconds.
And a short time after:
[02:37:46] Application AppCFC_36 Ended...
[02:37:46] Application AppCFC_35 Ended...
Since the last requests were done on AppCFC_36 the last, shouldn't it be the one ending last? I'm lost.
One last thing is that on the server monitor, even though I specify 1min for application variables, they still show up on the server monitor after a few minutes (and when I notice they output a log entry).
I logged the functions onApplicationStart and onApplicationEnd. Here is a small example of what happens:
[02:35:51] Application AppCFC_35 Started...
[02:36:00] Application AppCFC_36 Started...
This was having a javascript refresh the page every few seconds for not even 30 seconds.
And a short time after:
[02:37:46] Application AppCFC_36 Ended...
[02:37:46] Application AppCFC_35 Ended...
Since the last requests were done on AppCFC_36 the last, shouldn't it be the one ending last? I'm lost.
One last thing is that on the server monitor, even though I specify 1min for application variables, they still show up on the server monitor after a few minutes (and when I notice they output a log entry).
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advocate
,
/t5/coldfusion-discussions/applicationtimeout/m-p/380443#M34346
Apr 18, 2008
Apr 18, 2008
Copy link to clipboard
Copied
Well something is certainly not right, because th application
should not timeout if there is activity in the browser.
Something is mis-configured. First of all, do you have Enable Session Variables checked under Administrator>>Memory Variables? And do you have an appropriate amount of time set for the default session timeout and the maximum session timeout? For testing, I would set maximum and default to 20 minutes (0,0,20,0). Then I would set the application.cfc to 2 minutes using the following at the top of the Application.cfc.
<cfcomponent displayname="Application" output="false">
<cfscript>
this.name="AppName";
this.sessionmanagement="true";
this.sessionTimeout="#CreateTimeSpan(0,0,2,0)#";
this.setclientcookies="yes";
</cfscript>
...
</cfcomponent>
If the problem persists, then something else is wrong (obviously). But the behavior you are experiencing is not right.
Something is mis-configured. First of all, do you have Enable Session Variables checked under Administrator>>Memory Variables? And do you have an appropriate amount of time set for the default session timeout and the maximum session timeout? For testing, I would set maximum and default to 20 minutes (0,0,20,0). Then I would set the application.cfc to 2 minutes using the following at the top of the Application.cfc.
<cfcomponent displayname="Application" output="false">
<cfscript>
this.name="AppName";
this.sessionmanagement="true";
this.sessionTimeout="#CreateTimeSpan(0,0,2,0)#";
this.setclientcookies="yes";
</cfscript>
...
</cfcomponent>
If the problem persists, then something else is wrong (obviously). But the behavior you are experiencing is not right.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
sk8save
AUTHOR
Explorer
,
/t5/coldfusion-discussions/applicationtimeout/m-p/380444#M34347
Apr 21, 2008
Apr 21, 2008
Copy link to clipboard
Copied
- I have the memory variables checked.
Maximum timeout: application: 2 days. session: 2 days
Default timeout: application: 2 days. session: 20 minutes
I've changed this as I assume these were the default values (jeeze, 2 days?!) Session and application, maximum and default are all set to 20 minutes.
I still get it (even after having rebooted)...
<!--- Set up the application. --->
<cfset THIS.Name = "ThreadTest#minute(now())#" />
<cfset THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 2, 0 ) />
<cfset THIS.SessionManagement = true />
<cfset THIS.SetClientCookies = true /
Maximum timeout: application: 2 days. session: 2 days
Default timeout: application: 2 days. session: 20 minutes
I've changed this as I assume these were the default values (jeeze, 2 days?!) Session and application, maximum and default are all set to 20 minutes.
I still get it (even after having rebooted)...
<!--- Set up the application. --->
<cfset THIS.Name = "ThreadTest#minute(now())#" />
<cfset THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 2, 0 ) />
<cfset THIS.SessionManagement = true />
<cfset THIS.SetClientCookies = true /
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advocate
,
/t5/coldfusion-discussions/applicationtimeout/m-p/380446#M34349
Apr 21, 2008
Apr 21, 2008
Copy link to clipboard
Copied
Very strange indeed.
First, the 2 days Application Time out is not that bad. You probably don;t want your application to timeout if it goes unused for 20 minutes. That is usually not necessary and it costs overhead to reinitialize your application. i would set it back to the two days. Most heavily used apps will rarely reinitialize since they get hit more often then every couple of days. And then if you want to reinitialize the app then you can restart the server (not good) or you can add something like this to your onRequestStart():
<cfif IsDefined("url.reinit")>
<cfscript>
onApplicationStart();
</cfscript>
</cfif>
Now, back to the problem at hand. Your Application.cfc looks fine to me. I wonder if anyone else sees an issue. My next question would be about your browser. Is your cookie being maintained. Session management still requires a cookie. So if you have cookies disabled, or if you have some kind of cookie management utility, then perhaps that is causing you issues. Have you tried the app in another browser? Or on another computer?
In the meantime, i will still think on this.
One final thought. I have never used the <return true /> that you have at the bottom of your onApplicationStart(). I don't know if that is a good idea or not, I have never seen it. I don;t know why it would cause problems, but you never know.
Jason
First, the 2 days Application Time out is not that bad. You probably don;t want your application to timeout if it goes unused for 20 minutes. That is usually not necessary and it costs overhead to reinitialize your application. i would set it back to the two days. Most heavily used apps will rarely reinitialize since they get hit more often then every couple of days. And then if you want to reinitialize the app then you can restart the server (not good) or you can add something like this to your onRequestStart():
<cfif IsDefined("url.reinit")>
<cfscript>
onApplicationStart();
</cfscript>
</cfif>
Now, back to the problem at hand. Your Application.cfc looks fine to me. I wonder if anyone else sees an issue. My next question would be about your browser. Is your cookie being maintained. Session management still requires a cookie. So if you have cookies disabled, or if you have some kind of cookie management utility, then perhaps that is causing you issues. Have you tried the app in another browser? Or on another computer?
In the meantime, i will still think on this.
One final thought. I have never used the <return true /> that you have at the bottom of your onApplicationStart(). I don't know if that is a good idea or not, I have never seen it. I don;t know why it would cause problems, but you never know.
Jason
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
sk8save
AUTHOR
Explorer
,
/t5/coldfusion-discussions/applicationtimeout/m-p/380447#M34350
Apr 22, 2008
Apr 22, 2008
Copy link to clipboard
Copied
quote:
Originally posted by: 12Robots
Now, back to the problem at hand. Your Application.cfc looks fine to me. I wonder if anyone else sees an issue. My next question would be about your browser. Is your cookie being maintained. Session management still requires a cookie. So if you have cookies disabled, or if you have some kind of cookie management utility, then perhaps that is causing you issues. Have you tried the app in another browser? Or on another computer?
In the meantime, i will still think on this.
One final thought. I have never used the <return true /> that you have at the bottom of your onApplicationStart(). I don't know if that is a good idea or not, I have never seen it. I don;t know why it would cause problems, but you never know.
I've done the following:
- updated CF to the latest version
- tried in IE 6 and FF 2
- made sure cookies were enabled
- tried on a different server
I still get the same issues... very puzzling.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/applicationtimeout/m-p/380448#M34351
Apr 22, 2008
Apr 22, 2008
Copy link to clipboard
Copied
sk8save wrote:
> <!--- Set up the application. --->
> <cfset THIS.Name = "ThreadTest#minute(now())#" />
Is this intended. You are creating a new application every time this
line is run. These are all independent applications and they will
timeout in the specified time. Because each browser refresh is creating
a separate and distinct application, they will not reset the previous
application.
> <!--- Set up the application. --->
> <cfset THIS.Name = "ThreadTest#minute(now())#" />
Is this intended. You are creating a new application every time this
line is run. These are all independent applications and they will
timeout in the specified time. Because each browser refresh is creating
a separate and distinct application, they will not reset the previous
application.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advocate
,
/t5/coldfusion-discussions/applicationtimeout/m-p/380449#M34352
Apr 22, 2008
Apr 22, 2008
Copy link to clipboard
Copied
I did some testing. And then I slapped myself on the
forehead.
You have a variable Application name that is changing every minute. When the app name changes, onApplicationStart() is executed.
Try this Appliction.cfc:
<cfcomponent
displayname="Application"
output="true">
<!--- Set up the application. --->
<cfset THIS.Name = "AppCFC" />
<cfset THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 1, 0 ) />
<cfset THIS.SessionTimeout = CreateTimeSpan( 0, 0, 1, 0 ) />
<cfset THIS.SessionManagement = true />
<cfset THIS.SetClientCookies = true />
<cffunction
name="OnApplicationStart"
access="public"
returntype="boolean"
output="true">
<cfscript>
logValue("Application " & this.name & " Started...");
</cfscript>
<cfoutput>New App!</cfoutput>
<cfreturn true />
</cffunction>
<cffunction
name="OnApplicationEnd"
access="public"
returntype="void"
output="false">
<cfscript>
logValue("Application " & this.name & " Ended...");
</cfscript>
<!--- Return out. --->
<cfreturn />
</cffunction>
<cffunction name="onRequestStart" access="public">
<cfif IsDefined("url.reinit")>
<cfscript>
onApplicationStart();
</cfscript>
</cfif>
</cffunction>
<cffunction
name="LogValue"
access="public"
output="true"
hint="Logs the given value to a local log.">
<!--- Define arguments. --->
<cfargument
name="Value"
type="string"
required="true"
hint="The value to be logged."
/>
<cfoutput>#arguments.value#<br />
#datePart("n",now())#</cfoutput>
</cffunction>
</cfcomponent>
You'll notice that if you then change the name of the App manually, that it will reinitialize.
You have a variable Application name that is changing every minute. When the app name changes, onApplicationStart() is executed.
Try this Appliction.cfc:
<cfcomponent
displayname="Application"
output="true">
<!--- Set up the application. --->
<cfset THIS.Name = "AppCFC" />
<cfset THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 1, 0 ) />
<cfset THIS.SessionTimeout = CreateTimeSpan( 0, 0, 1, 0 ) />
<cfset THIS.SessionManagement = true />
<cfset THIS.SetClientCookies = true />
<cffunction
name="OnApplicationStart"
access="public"
returntype="boolean"
output="true">
<cfscript>
logValue("Application " & this.name & " Started...");
</cfscript>
<cfoutput>New App!</cfoutput>
<cfreturn true />
</cffunction>
<cffunction
name="OnApplicationEnd"
access="public"
returntype="void"
output="false">
<cfscript>
logValue("Application " & this.name & " Ended...");
</cfscript>
<!--- Return out. --->
<cfreturn />
</cffunction>
<cffunction name="onRequestStart" access="public">
<cfif IsDefined("url.reinit")>
<cfscript>
onApplicationStart();
</cfscript>
</cfif>
</cffunction>
<cffunction
name="LogValue"
access="public"
output="true"
hint="Logs the given value to a local log.">
<!--- Define arguments. --->
<cfargument
name="Value"
type="string"
required="true"
hint="The value to be logged."
/>
<cfoutput>#arguments.value#<br />
#datePart("n",now())#</cfoutput>
</cffunction>
</cfcomponent>
You'll notice that if you then change the name of the App manually, that it will reinitialize.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
sk8save
AUTHOR
Explorer
,
/t5/coldfusion-discussions/applicationtimeout/m-p/380450#M34353
Apr 22, 2008
Apr 22, 2008
Copy link to clipboard
Copied
Okay, both solutions worked.
However, now, the onApplicationEnd doesn't fire. I wonder if it's related to the cfthread I create onApplicationStart?
Edit: that's what it was. As soon as I terminated the thread in cfadmin, the log fired.
However, now, the onApplicationEnd doesn't fire. I wonder if it's related to the cfthread I create onApplicationStart?
Edit: that's what it was. As soon as I terminated the thread in cfadmin, the log fired.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/coldfusion-discussions/applicationtimeout/m-p/380451#M34354
Apr 22, 2008
Apr 22, 2008
Copy link to clipboard
Copied
I am not certain if I am missing something, but I am getting
the idea you are confusing APPLICATION and SESSION scopes
Your website is generally the application and it is constantly running the timer until such time as it hits the default (or set timeout) or the server is restarted. It does not restart every time browser activity is detected. The APPLICATION scope holds information that is available to everyone who uses your site and only refreshes itself once a timeout is set by the server (i.e. 2 days by default) - not the end user.
The current browser activity by an individual is the SESSION and that is what should be restarting each time a page is refreshed etc.
onApplicationEnd will not fire until the APPLICATION ends (i.e. 2 days by default) . onSessionEnd is what you should be using if you want something to happen when the user leaves or a session timesout.
That's just my opinion from reading through everything.
Your website is generally the application and it is constantly running the timer until such time as it hits the default (or set timeout) or the server is restarted. It does not restart every time browser activity is detected. The APPLICATION scope holds information that is available to everyone who uses your site and only refreshes itself once a timeout is set by the server (i.e. 2 days by default) - not the end user.
The current browser activity by an individual is the SESSION and that is what should be restarting each time a page is refreshed etc.
onApplicationEnd will not fire until the APPLICATION ends (i.e. 2 days by default) . onSessionEnd is what you should be using if you want something to happen when the user leaves or a session timesout.
That's just my opinion from reading through everything.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
sk8save
AUTHOR
Explorer
,
LATEST
/t5/coldfusion-discussions/applicationtimeout/m-p/380452#M34355
Apr 22, 2008
Apr 22, 2008
Copy link to clipboard
Copied
I thought that if you put in a value, that's when it would
expire? If you don't indicate a length of time, then, it will take
the CF default which is 20?
In my case, I put in 2 minutes as this is just for testing. And this was confirmed logging text to a file when doing onApplicationStart and onApplicationEnd. The only thing was, I was firing a thread onApplicationStart and this kept the application alive. As soon as I terminated it in cfadmin, the application timed out properly.
I miss interpreted the server monitor active session screen. I thought it meant application sessions (now, I don't know why would think that). So everything is good on all fronts.
In my case, I put in 2 minutes as this is just for testing. And this was confirmed logging text to a file when doing onApplicationStart and onApplicationEnd. The only thing was, I was firing a thread onApplicationStart and this kept the application alive. As soon as I terminated it in cfadmin, the application timed out properly.
I miss interpreted the server monitor active session screen. I thought it meant application sessions (now, I don't know why would think that). So everything is good on all fronts.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

