I have a ASP.NET Web Forms application that internally makes many SOAP and REST calls to web services. The SOAP calls are made using Microsoft's own "wrapping" code. The REST calls are made from a simple REST client. This client uses Using blocks to dispose of any resources.
The application runs fine for a few hours but then hangs up. The site will no longer be able to serve up asp.net pages. I tested the site by putting a hello.htm file on it... it served up fine. So it is definitely a problem in the ASP.NET engine space.
It feels like it has run out of webrequests from a pool. I could be way off. What can I try? What should I look at? It takes hours to get the problem to repro. Restarting the site on IIS fixes the issue, but of cource is not really a fix we can live with.
start of error and stack trace:
Server Error in '/' Application.
The operation has timed out Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The operation has timed out
Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: [WebException: The operation has timed out] System.Net.HttpWebRequest.GetRequestStream() +5322142 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +103
UPDATE and MORE INFO
The homegrown REST calls and SOAP are all done synchronous.
They are not long-lived they take about 1 sec.
Web Services are hosted on a Tomcat server (different machine) in the same data center.
The .NET app calls SOAP and REST services on the Tomcat server.
The app somehow fixed itself after about an hour of staying in this hung state. Thoughts? How do I monitor the .NET Threadpool? Does DefaultConnectionLimit affect the self-initiated outbound connections?
RESOLUTION
see additional comments to answers and...
1) close all streams and responses/requests from your homegrown REST code (oops)
2) System.Net.ServicePointManager.DefaultConnectionLimit = 96;
// default = 12 times # of cores
System.Net.ServicePointManager.MaxServicePointIdleTime= 3000;
// default = 100000 (100 seconds)
By fixing any leaky code and timing out the IdleTime faster everything seems to work fine now