Problems with WebRequest and Connection

G

GSK

This one has me stumped:

I am using HttpWebRequest to resolve an external URL (that outputs an XML
string). It works fine on my dev machine (W2K), and used to work on my
production machine (W2K3). It seems that now, for some reason, the
connection cannot be established. The error logged is:

The underlying connection was closed: Unable to connect to the remote
server." source="System" stack="at
System.Net.HttpWebRequest.CheckFinalStatus()..."

I can connect to the Internet via the browser on this machine, and all
network related services seem to be working. (Terminal services, etc.) I've
fiddled with the Timeout on the WebRequest object to no avail. The most
frustrating thing is that it recently worked - once - then stopped working
again. I'm not sure if it is a network issue, hardware issue, security issue
on W2K3, etc.?

Any help would be appreciated.

Here is the function called:

private string readHtmlPage(string url)
{
string _result;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
using (StreamReader sr = new
StreamReader(objResponse.GetResponseStream()) )
{
_result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return _result;
}

Thanks!

- gsk.
 
J

Joerg Jooss

GSK said:
This one has me stumped:

I am using HttpWebRequest to resolve an external URL (that outputs an
XML string). It works fine on my dev machine (W2K), and used to work
on my production machine (W2K3). It seems that now, for some reason,
the connection cannot be established. The error logged is:

The underlying connection was closed: Unable to connect to the remote
server." source="System" stack="at
System.Net.HttpWebRequest.CheckFinalStatus()..."

I can connect to the Internet via the browser on this machine, and all
network related services seem to be working. (Terminal services,
etc.) I've fiddled with the Timeout on the WebRequest object to no
avail. The most frustrating thing is that it recently worked - once -
then stopped working again. I'm not sure if it is a network issue,
hardware issue, security issue on W2K3, etc.?

Any help would be appreciated.

[...]

Are you using a proxy in IE? You don't specify one in your code.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top