J
Jason
I'm having a hard time getting a call to HttpWebRequest's
GetRequestSteam to work. Each time I try to run it, I get the
following error:
The underlying connection was closed: Unable to connect to the
remote server.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The underlying
connection was closed: Unable to connect to the remote server.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location
of the exception can be identified using the exception stack trace
below.
Stack Trace:
[WebException: The underlying connection was closed: Unable to
connect to the remote server.]
System.Net.HttpWebRequest.CheckFinalStatus() +677
System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult
asyncResult) +75
System.Net.HttpWebRequest.GetRequestStream() +233
ERSI.Store.UPSShipping.RequestShipping() +113
...
The code I use works perfectly on both my development machine and on
another webserver where we host our main website. However, when I try
to run this on a our internal company web server (running Microsoft
Small Business Server, ISA Firewall, and IIS 6), it seems to timeout
and give me the error above.
The following code produces the error:
string szResponse = "";
Uri url = new Uri("https://www.ups.com/ups.app/xml/Rate");
HttpWebRequest connection = (HttpWebRequest)WebRequest.Create(url);
connection.UnsafeAuthenticatedConnectionSharing = true;
connection.Method = "POST";
Stream output = connection.GetRequestStream(); // <-- Error Thrown
string szXML = GetRequestString();
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] request = encoding.GetBytes(szXML);
output.Write(request, 0, request.Length);
output.Close();
HttpWebResponse resp = (HttpWebResponse)connection.GetResponse();
StreamReader strStream = new StreamReader(resp.GetResponseStream(),
Encoding.ASCII);
try {
szResponse = strStream.ReadToEnd();
} catch (Exception exc) {
System.Diagnostics.Debug.WriteLine(exc.StackTrace);
}
resp.Close();
Because it works great on both our development machines and our main
websites, I don't think that the problem is with the code, but rather
some setting in ISA or SBS. I would appreciate any suggestions on how
to fix the problem or even an alternate newsgroup to try if nobody has
any ideas. Thanks.
GetRequestSteam to work. Each time I try to run it, I get the
following error:
The underlying connection was closed: Unable to connect to the
remote server.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The underlying
connection was closed: Unable to connect to the remote server.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location
of the exception can be identified using the exception stack trace
below.
Stack Trace:
[WebException: The underlying connection was closed: Unable to
connect to the remote server.]
System.Net.HttpWebRequest.CheckFinalStatus() +677
System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult
asyncResult) +75
System.Net.HttpWebRequest.GetRequestStream() +233
ERSI.Store.UPSShipping.RequestShipping() +113
...
The code I use works perfectly on both my development machine and on
another webserver where we host our main website. However, when I try
to run this on a our internal company web server (running Microsoft
Small Business Server, ISA Firewall, and IIS 6), it seems to timeout
and give me the error above.
The following code produces the error:
string szResponse = "";
Uri url = new Uri("https://www.ups.com/ups.app/xml/Rate");
HttpWebRequest connection = (HttpWebRequest)WebRequest.Create(url);
connection.UnsafeAuthenticatedConnectionSharing = true;
connection.Method = "POST";
Stream output = connection.GetRequestStream(); // <-- Error Thrown
string szXML = GetRequestString();
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] request = encoding.GetBytes(szXML);
output.Write(request, 0, request.Length);
output.Close();
HttpWebResponse resp = (HttpWebResponse)connection.GetResponse();
StreamReader strStream = new StreamReader(resp.GetResponseStream(),
Encoding.ASCII);
try {
szResponse = strStream.ReadToEnd();
} catch (Exception exc) {
System.Diagnostics.Debug.WriteLine(exc.StackTrace);
}
resp.Close();
Because it works great on both our development machines and our main
websites, I don't think that the problem is with the code, but rather
some setting in ISA or SBS. I would appreciate any suggestions on how
to fix the problem or even an alternate newsgroup to try if nobody has
any ideas. Thanks.