2

Firstly, there are a number of other similar questions and I have read them all and they have a similar problem however they differ from my problem:

In a WPF client application I am making several HttpWebRequests to various websites. On one particular machine and for one particular website I receive the following error, however only intermittently, approximately once every 4 or 5 requests:

System.Net.WebException The underlying connection was closed: An unexpected error occurred on a receive. at System.Net.HttpWebRequest.GetResponse()

and the status on the Request is ReceiveFailure.

Here's what I've tried:

  • Changing the timeout to be very high, turning off keep alive and using http 1.0 instead of 1.1, all of which don't change the problem
  • Running through a proxy to see what was going on but for some strange reason this problem doesn't happen when I run the exact same code through a proxy (by setting the proxy object on the http web request)
  • I can access the site no problem with IE and chrome
  • Tried another machine inside on my home network and had no problems. Similarly with another machine outside of the network.

This problem happened after upgrading this machine to Win7 however after going back to WinXP the problem is still ocurring.

Any help is greatly appreciated, all of the other posts either were for people talking to their own webservices and it was an ASP configuration problem or something like that. The site I am making requests too is an ASP site but I don't believe its a problem with the 3rd party site as this exact same code works on other machines just not one particular one.

1 Answers1

2

A ReceiveFailure status means that your application started receiving the response but it was closed before the complete message was received for some reason.

Since you've already changed the timeout etc with no success the problem might be the server is closing the response stream prior to a complete response for some reason. Isolated to a specific machine might indicate a possible hardware issue or configuration on that particular machine. The fact that it's only for one website on the machine indicates configuration rather than hardware. Is there something different on that machine? Updates? IIS configuration?

It might be working through IE, Chrome and the Proxy because those would have some error handling already built in (IE and Chrome would definitely have error handling and retry the requests, I assume the proxy would too). You may have to build some of this error handling into your code.

WilliamB
  • 154
  • 1