HttpWebRequest.GetRequestStream:Unable to connect to the remote se

E

Edgile

Hello Everyone,

System.Net.WebException Unable to connect to the remote server at
System.Net.HttpWebRequest.GetRequestStream()

This is the exception I am confronted with when I deploy my website on a
W2003 Standard Edition server though the same code runs perfectly on other
two developer servers (XP Professional). This GetRequestStream method is
executed on the web server when invoking a remote web service. Then it waits
until a timeout and I get this exception. The web service invokation uses
HTTP POST. If I fire an HTTP GET from a browser of the problematic server to
the same remote web service (same URL), I get the correct response
immediately that is an error report insturcting me to use HTTP POST . I am
pretty certain that this is not a software issue, but rather a security
settings problem of W2003 Server. Can you help me with any advise?

Thnx!
 
J

John Saunders [MVP]

Edgile said:
Hello Everyone,

System.Net.WebException Unable to connect to the remote server at
System.Net.HttpWebRequest.GetRequestStream()

This is the exception I am confronted with when I deploy my website on a
W2003 Standard Edition server though the same code runs perfectly on other
two developer servers (XP Professional). This GetRequestStream method is
executed on the web server when invoking a remote web service. Then it
waits
until a timeout and I get this exception. The web service invokation uses
HTTP POST. If I fire an HTTP GET from a browser of the problematic server
to
the same remote web service (same URL), I get the correct response
immediately that is an error report insturcting me to use HTTP POST . I am
pretty certain that this is not a software issue, but rather a security
settings problem of W2003 Server. Can you help me with any advise?

Was this the entire exception message? In particular, I suspect there was an
inner exception detailing _why_ it was unable to connect to the remote
server.

Additionally, was there anything in the event logs either for the invoking
server or the remote server?
 
E

Edgile

Hello John,

You were right. I did have InnerException, but due to the limited debugging
means on the deployment machines I did not notice that. I have checked the
event log on the deployment machine, but found nothing. As far as the host of
the remote web service, I have no control over it.

Here is the complete exception description:

System.Net.WebException Unable to connect to the remote server at
System.Net.HttpWebRequest.GetRequestStream() at ...

Inner exception: System.Net.Sockets.SocketException Message: A connection
attempt failed because the connected party did not properly respond after a
period of time, or established connection failed because connected host has
failed to respond | at System.Net.Sockets.Socket.DoConnect(EndPoint
endPointSnapshot, SocketAddress socketAddress) at
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket
s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state,
IAsyncResult asyncResult, Int32 timeout, Exception& exception)

This looks very strange to me as the service does react promptly on HTTP GET.
Thanx in advance, if you have ideas!
 
J

John Saunders [MVP]

Edgile said:
Hello John,

You were right. I did have InnerException, but due to the limited
debugging
means on the deployment machines I did not notice that. I have checked the
event log on the deployment machine, but found nothing. As far as the host
of
the remote web service, I have no control over it.

Here is the complete exception description:

System.Net.WebException Unable to connect to the remote server at
System.Net.HttpWebRequest.GetRequestStream() at ...

Inner exception: System.Net.Sockets.SocketException Message: A connection
attempt failed because the connected party did not properly respond after
a
period of time, or established connection failed because connected host
has
failed to respond | at System.Net.Sockets.Socket.DoConnect(EndPoint
endPointSnapshot, SocketAddress socketAddress) at
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
Socket
s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState
state,
IAsyncResult asyncResult, Int32 timeout, Exception& exception)

This looks very strange to me as the service does react promptly on HTTP
GET.
Thanx in advance, if you have ideas!

Ok, so it timed out on an HTTP POST but works with HTTP GET. Whenever you
see a timeout, you should ask, "how long does it _want_ to take to
complete?".

Sometimes, the answer is "forever". Check to see if it's configured to
handle HTTP POST at all. It may not ever be receiving the request.
 
K

Kevin

I just had this exact same issue. I resolved it by editing the system.net section of my web service's web.config file. The server that I migrated my code to had tight restrictions on its net use, and .NET 2.0 and higher uses the proxy by default when making HTTP calls using System.Net. The problem was solved by editing the system.net config section to not use the default proxy during calls.

I added the following xml to web.config (hopefully the xml is allowed in this post):

<system.net>
<defaultProxy>
<proxy bypassonlocal="True" usesystemdefault="False" />
</defaultProxy>
</system.net>

For a better explanation than mine, check out the following link:
http://west-wind.com/weblog/posts/3871.aspx
 

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,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top