I do HttpRequests for an external server from my ASP.NET application, to a URL, for example, for example:
https:
The server runs a service that responds to these requests using xml (for example, web services). My code makes a GET request as follows:
var wc = new System.Net.WebClient(); wc.Credentials = credentials; // username and password for service // get data from server. string s = Encoding.ASCII.GetString(wc.DownloadData(url)); return s;
It works great on my development machine.
But on my test computer (old Windows Server 2003 64 server) it is with this exception:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred while sending.
---> System.IO.IOException: cannot read data from transport connection: existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: existing connection was forcibly closed by the remote host
Googling tells me that this error has about a million different possible causes. It seems not.
More details:
- I can make a request by pasting the URL into the browser and it works on the Dev server, but on the test server it works in Firefox, but not IE (!?!) IE gives the general "Internet Explorer cannot display the web page" looks exactly the same if I change the IP address to something that does not exist.
- The server is protected by a self-signed SSL certificate, which was added to the local computer trusted certificate store on both clients (test and dev boxes). But this is unlikely a problem with the certificate , since it works fine on dev, and it still happens if you ignore certificate verification (when testing).
- I can install telnet on the server (with the correct IP and port) from the test window.
Can anyone suggest trying something? Possible reason? A way to narrow it down a bit?
Mgowen
source share