Blog Stats
  • Posts - 17
  • Articles - 2
  • Comments - 16
  • Trackbacks - 1

 

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

Feedback

No comments posted yet.


Post a comment





 

 

 

Copyright © Shailen Sukul