Groups | Blog | Home
all groups > asp.net webservices > september 2007 >

asp.net webservices : HttpWebRequest.GetRequestStream:Unable to connect to the remote se


Edgile
9/19/2007 6:22:02 AM
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?

John Saunders [MVP]
9/19/2007 11:55:57 AM
[quoted text, click to view]

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?
--
--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer
Edgile
9/20/2007 12:36:04 AM
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!


[quoted text, click to view]
John Saunders [MVP]
9/20/2007 1:18:33 PM
[quoted text, click to view]

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.
--
--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer
AddThis Social Bookmark Button