Thursday, February 17, 2011

Solving Debugging Timeout problem in Visual Studio and IIS7

For those who wonders why debugging time out occurs in Visual Studio, and how to solve the timeout problem, this post is for them.

It was kind of irritating to see the debugging process killed automatically when debugging a web site/application in Visual Studio hosted in IIS 7, after installing Windows 7 in my PC. I wonder why that used to happen because it did never happen in case of web site/application hosted in IIS 6.0. In first few days, I used to try to complete my debugging works in a hurry (Say, within 30-40 seconds), but, I couldn't continue this for long, and hence, decided to explore this issue a bit. Well, as it turned out, this was a matter of changing some settings in the corresponding Application pool in IIS.

Take a look at the following screen shot. This has been taken by Right clicking on the Application pool of an web site/application and selecting "Advaced Settings":

Ping Enable property of Application pool in IIS

Figure : Ping Enable property of Application pool in IIS
There is a health monitoring system in IIS (Enabled if the property "Ping Enabled=true" for the corresponding Application pool), which pings the worker process periodically, to make sure that the process is responsive, healthy and alive. Now, when the Ping Enabled value is set to "true" (Which is by default), the debugging timeout occurs occurs in Visual Studio while debugging an web site or application. The reason is, while debugging, the process is simply halted at the break point, and hence, it cannot response back to the health monitoring system's ping.

Now, when the health monitoring system doesn't get any response from the worker process, it immediately doesn't kill the process. It waits for the period of time specified in seconds (By the Application pool's property "Ping Maximum Response Time In Seconds") and then kills the worker process. Hence, the debugging process gets killed in Visual Studio.

So, to solve the debuggin timeout issue, either of the following two approaches could be followed:

Disable health monitoring

The easiest solution is to disable health monitoring by setting the value "Ping Enabled"=false. This would prevent the situation from happening which leads to kill the debugging process when it is unable to give any response from the health monitoring ping. This allows to be able to debug and wait at a break point for an infinite amount of time without any problem.

However, the pay off is, the health monitoring process is no longer enabled, and hence, there is no way for the administrator to get notified about any possible issues which could lead to make the web site/application down or perform sluggishly. Fortunately, in your development PC, this is probably not needed at all, and hence, disabling health monitoring could be an easy solution for you.

Increase Maximum Response Time

As said already, while debugging, when the worker process gives no response to the health monitoring ping, it waits for a certain amount of time and then kills the debugging process (Worker process). So, another approach could be to increase the waiting time long enough (Say, 600 seconds or 10 minutes) to be able to debug a particular problem. A good thing with this approach is, the health monitoring process is still enabled, and, you can adjust the waiting time as much as you need, which is handy.


Anonymous said...

Thanks, just what I needed!

High-Flying said...

Thanks, this has been crashing my debug sessions for too long!

Anonymous said...

thanks man...very valuble info when debugging :)

Dhaval D said...

Awesome. I was using stack trace and error logs to debug. This would be a life saver!

Thanks for the advice.

Anonymous said...

Thanks a lot.

Anonymous said...

it looks like, work fine!
thank you!

johir said...

nice article

Bruce allen said...

I have been frustrated by this for a year!!
Several times I have googled for solution, but nothing worked. I am now FREE to debug almost twice as fast!


Anonymous said...

Thank you for the comprenesive explanation and solution.

Post a Comment