posts - 18, comments - 23, trackbacks - 1

My Links

News

This blog has moved to http://shailen.sukul.org

Article Categories

Archives

Post Categories

Intermittent Web Services Error

Intermittent Web Services Error

I have a proxy class that performs a large number of calls on a web service.
It fails intermittently with the following error:

System.Net.WebException: The request failed with HTTP status 401:
Unauthorized. at System.Web.Services.Protocols.SoapHttpClientProtocol.
ReadResponse(SoapClientMessage message, WebResponse response,
Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke
(String methodName, Object[] parameters)

To fix this, you should disable the Keep Alive feature on IIS and the proxy class.

Disable Keep Alive in IIS
To disable go to the Web site tab of the Web site properties window and uncheck the Keep Alive options.

Disable Keep Alive in Proxy
You need to override the default handling of WebRequest as shown below:

protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
System.Net.HttpWebRequest webRequest =
(System.Net.HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
return webRequest;
}

More Information on Keep Alive
Keep alive keeps the connection open across multiple requests.
To find out more, see: https://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/59e9c2d2-b772-4c43-82f0-e669427eeb89.mspx

and

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnethttpwebrequestclasskeepalivetopic.asp
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Friday, April 07, 2006 10:40 PM | Filed Under [ .Net Oddities ]

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: