Hello everyone,

I am having problems with Timers in a web application.
They just seem to stop running after 15 minutes or so.

My web application is set up like this:

When a user hits a page in the site, that page (.aspx)
instantiates a compiled class (.DLL). The instantiation
process creates a Timer that runs in the background to
perform tasks every so often (such as notifying clients
every 24 hours if something is overdue, etc.).

The problem seems to be that if the site goes idle, the
timer just dies after awhile. I've searched high and low
to find a solution for this, but can't seem to find any
answers. I have checked the processModel of my
machine.config and all of the timeout settings
are "Infinite".

So, just for fun, I built one of my timers to run every
minute and log some text to a file. That way I could
tell when it is aborting. I start up the application and
it prints a line every minute in the log, so I decide to
go to bed. I look at it in the morning to see that it
stopped after 18 lines in the log. I probably used the
site for about 3 minutes before going to bed, so I'm
assuming this is a 15 minute timeout.

Nothing in the timer code tells them to abort or
reschedule or anything. The only line of code for this
timer is to print the line to the log.

The only solution I have found that works is to use the
scheduler (this is a Windows 2000 server, by the way) in
the control panel. I have created a scheduled task to
run every 10 minutes that will open Internet Explorer and
hit my web site, therefore keeping it active (or starting
it back up if it went idle).

It seems like there should be a way to keep the timers
persistent for an infinite amount of time. Could it be
the garbage collector destroying an object reference? Is
it just the web application shutting down?

Oh, and as another note, the web application doesn't
*seem* to be shutting down entirely if it is shutting
down. I have my system set up so that when the first
instantiation occurs, a few logs are printed out. That
way I can see what's happening when the application
starts. Every time I change web.config or recompile my
DLLs, the application restarts (as it should) and I see
the new logs. However, when I leave my application
running overnight, then come in in the morning, the
application has not shut down because no "startup
messages" are appearing in my logs. Yet the timers are
dying still.

Sorry about the long-winded question, but I thought I
needed to provide a good amount of information.

I greatly appreciate any help someone can provide. Thank
you in advance for looking at this.

Hegg

Re: Timers aborting in web application by Alvin

Alvin
Thu Dec 18 11:27:59 CST 2003

where is your timer setup?

It can't be on a page, cuz the page doesn't last very long and will be
subject to collection once the page goes away. Put your timer in global.aspx
and start it up in the application_start event. My timer runs for weeks
without problem this way as long as the application is running.

--
Regards,
Alvin Bruney
Got DotNet? Get it here
http://home.networkip.net/dotnet/tidbits/default.htm
"Hegg" <hegg@netwidedev.com> wrote in message
news:0d4201c3c58a$3f19a5b0$a601280a@phx.gbl...
> Hello everyone,
>
> I am having problems with Timers in a web application.
> They just seem to stop running after 15 minutes or so.
>
> My web application is set up like this:
>
> When a user hits a page in the site, that page (.aspx)
> instantiates a compiled class (.DLL). The instantiation
> process creates a Timer that runs in the background to
> perform tasks every so often (such as notifying clients
> every 24 hours if something is overdue, etc.).
>
> The problem seems to be that if the site goes idle, the
> timer just dies after awhile. I've searched high and low
> to find a solution for this, but can't seem to find any
> answers. I have checked the processModel of my
> machine.config and all of the timeout settings
> are "Infinite".
>
> So, just for fun, I built one of my timers to run every
> minute and log some text to a file. That way I could
> tell when it is aborting. I start up the application and
> it prints a line every minute in the log, so I decide to
> go to bed. I look at it in the morning to see that it
> stopped after 18 lines in the log. I probably used the
> site for about 3 minutes before going to bed, so I'm
> assuming this is a 15 minute timeout.
>
> Nothing in the timer code tells them to abort or
> reschedule or anything. The only line of code for this
> timer is to print the line to the log.
>
> The only solution I have found that works is to use the
> scheduler (this is a Windows 2000 server, by the way) in
> the control panel. I have created a scheduled task to
> run every 10 minutes that will open Internet Explorer and
> hit my web site, therefore keeping it active (or starting
> it back up if it went idle).
>
> It seems like there should be a way to keep the timers
> persistent for an infinite amount of time. Could it be
> the garbage collector destroying an object reference? Is
> it just the web application shutting down?
>
> Oh, and as another note, the web application doesn't
> *seem* to be shutting down entirely if it is shutting
> down. I have my system set up so that when the first
> instantiation occurs, a few logs are printed out. That
> way I can see what's happening when the application
> starts. Every time I change web.config or recompile my
> DLLs, the application restarts (as it should) and I see
> the new logs. However, when I leave my application
> running overnight, then come in in the morning, the
> application has not shut down because no "startup
> messages" are appearing in my logs. Yet the timers are
> dying still.
>
> Sorry about the long-winded question, but I thought I
> needed to provide a good amount of information.
>
> I greatly appreciate any help someone can provide. Thank
> you in advance for looking at this.
>
> Hegg



Re: Timers aborting in web application by Jeff

Jeff
Thu Dec 18 11:35:32 CST 2003

Alvin,

I think that's what I'm looking for. Some place to globally start a
process. This should probably solve my problem, thank you very much.

As to your question about having it on the page, it's not "in the page" per
se, the page instantiates some classes that stay persistent for the
application. But now that you mention that, I guess the page would have to
keep some kind of handle on things, although I don't have a problem with
anything but the Timers "going away".

Thanks again, I'll give it a try and see if it solves my problems.

Jeff




"Alvin Bruney" <vapor at steaming post office> wrote in message
news:OivBLxYxDHA.2360@TK2MSFTNGP10.phx.gbl...
> where is your timer setup?
>
> It can't be on a page, cuz the page doesn't last very long and will be
> subject to collection once the page goes away. Put your timer in
global.aspx
> and start it up in the application_start event. My timer runs for weeks
> without problem this way as long as the application is running.
>
> --
> Regards,
> Alvin Bruney
> Got DotNet? Get it here
> http://home.networkip.net/dotnet/tidbits/default.htm
> "Hegg" <hegg@netwidedev.com> wrote in message
> news:0d4201c3c58a$3f19a5b0$a601280a@phx.gbl...
> > Hello everyone,
> >
> > I am having problems with Timers in a web application.
> > They just seem to stop running after 15 minutes or so.
> >
> > My web application is set up like this:
> >
> > When a user hits a page in the site, that page (.aspx)
> > instantiates a compiled class (.DLL). The instantiation
> > process creates a Timer that runs in the background to
> > perform tasks every so often (such as notifying clients
> > every 24 hours if something is overdue, etc.).
> >
> > The problem seems to be that if the site goes idle, the
> > timer just dies after awhile. I've searched high and low
> > to find a solution for this, but can't seem to find any
> > answers. I have checked the processModel of my
> > machine.config and all of the timeout settings
> > are "Infinite".
> >
> > So, just for fun, I built one of my timers to run every
> > minute and log some text to a file. That way I could
> > tell when it is aborting. I start up the application and
> > it prints a line every minute in the log, so I decide to
> > go to bed. I look at it in the morning to see that it
> > stopped after 18 lines in the log. I probably used the
> > site for about 3 minutes before going to bed, so I'm
> > assuming this is a 15 minute timeout.
> >
> > Nothing in the timer code tells them to abort or
> > reschedule or anything. The only line of code for this
> > timer is to print the line to the log.
> >
> > The only solution I have found that works is to use the
> > scheduler (this is a Windows 2000 server, by the way) in
> > the control panel. I have created a scheduled task to
> > run every 10 minutes that will open Internet Explorer and
> > hit my web site, therefore keeping it active (or starting
> > it back up if it went idle).
> >
> > It seems like there should be a way to keep the timers
> > persistent for an infinite amount of time. Could it be
> > the garbage collector destroying an object reference? Is
> > it just the web application shutting down?
> >
> > Oh, and as another note, the web application doesn't
> > *seem* to be shutting down entirely if it is shutting
> > down. I have my system set up so that when the first
> > instantiation occurs, a few logs are printed out. That
> > way I can see what's happening when the application
> > starts. Every time I change web.config or recompile my
> > DLLs, the application restarts (as it should) and I see
> > the new logs. However, when I leave my application
> > running overnight, then come in in the morning, the
> > application has not shut down because no "startup
> > messages" are appearing in my logs. Yet the timers are
> > dying still.
> >
> > Sorry about the long-winded question, but I thought I
> > needed to provide a good amount of information.
> >
> > I greatly appreciate any help someone can provide. Thank
> > you in advance for looking at this.
> >
> > Hegg
>
>



Re: Timers aborting in web application by Jeff

Jeff
Thu Dec 18 14:10:28 CST 2003

Thanks again Alvin, that works great. Just one little note for anyone else
that might be reading: you might wanna check out "global.asax" for
implementing your application_Start method.

Jeff


"Jeff Greenland" <jeffgWITHOUTSPAM@netwidedev.com> wrote in message
news:%23$tia1YxDHA.2712@TK2MSFTNGP11.phx.gbl...
> Alvin,
>
> I think that's what I'm looking for. Some place to globally start a
> process. This should probably solve my problem, thank you very much.
>
> As to your question about having it on the page, it's not "in the page"
per
> se, the page instantiates some classes that stay persistent for the
> application. But now that you mention that, I guess the page would have
to
> keep some kind of handle on things, although I don't have a problem with
> anything but the Timers "going away".
>
> Thanks again, I'll give it a try and see if it solves my problems.
>
> Jeff
>
>
>
>
> "Alvin Bruney" <vapor at steaming post office> wrote in message
> news:OivBLxYxDHA.2360@TK2MSFTNGP10.phx.gbl...
> > where is your timer setup?
> >
> > It can't be on a page, cuz the page doesn't last very long and will be
> > subject to collection once the page goes away. Put your timer in
> global.aspx
> > and start it up in the application_start event. My timer runs for weeks
> > without problem this way as long as the application is running.
> >
> > --
> > Regards,
> > Alvin Bruney
> > Got DotNet? Get it here
> > http://home.networkip.net/dotnet/tidbits/default.htm
> > "Hegg" <hegg@netwidedev.com> wrote in message
> > news:0d4201c3c58a$3f19a5b0$a601280a@phx.gbl...
> > > Hello everyone,
> > >
> > > I am having problems with Timers in a web application.
> > > They just seem to stop running after 15 minutes or so.
> > >
> > > My web application is set up like this:
> > >
> > > When a user hits a page in the site, that page (.aspx)
> > > instantiates a compiled class (.DLL). The instantiation
> > > process creates a Timer that runs in the background to
> > > perform tasks every so often (such as notifying clients
> > > every 24 hours if something is overdue, etc.).
> > >
> > > The problem seems to be that if the site goes idle, the
> > > timer just dies after awhile. I've searched high and low
> > > to find a solution for this, but can't seem to find any
> > > answers. I have checked the processModel of my
> > > machine.config and all of the timeout settings
> > > are "Infinite".
> > >
> > > So, just for fun, I built one of my timers to run every
> > > minute and log some text to a file. That way I could
> > > tell when it is aborting. I start up the application and
> > > it prints a line every minute in the log, so I decide to
> > > go to bed. I look at it in the morning to see that it
> > > stopped after 18 lines in the log. I probably used the
> > > site for about 3 minutes before going to bed, so I'm
> > > assuming this is a 15 minute timeout.
> > >
> > > Nothing in the timer code tells them to abort or
> > > reschedule or anything. The only line of code for this
> > > timer is to print the line to the log.
> > >
> > > The only solution I have found that works is to use the
> > > scheduler (this is a Windows 2000 server, by the way) in
> > > the control panel. I have created a scheduled task to
> > > run every 10 minutes that will open Internet Explorer and
> > > hit my web site, therefore keeping it active (or starting
> > > it back up if it went idle).
> > >
> > > It seems like there should be a way to keep the timers
> > > persistent for an infinite amount of time. Could it be
> > > the garbage collector destroying an object reference? Is
> > > it just the web application shutting down?
> > >
> > > Oh, and as another note, the web application doesn't
> > > *seem* to be shutting down entirely if it is shutting
> > > down. I have my system set up so that when the first
> > > instantiation occurs, a few logs are printed out. That
> > > way I can see what's happening when the application
> > > starts. Every time I change web.config or recompile my
> > > DLLs, the application restarts (as it should) and I see
> > > the new logs. However, when I leave my application
> > > running overnight, then come in in the morning, the
> > > application has not shut down because no "startup
> > > messages" are appearing in my logs. Yet the timers are
> > > dying still.
> > >
> > > Sorry about the long-winded question, but I thought I
> > > needed to provide a good amount of information.
> > >
> > > I greatly appreciate any help someone can provide. Thank
> > > you in advance for looking at this.
> > >
> > > Hegg
> >
> >
>
>