Pabitra Dash
Pabitra Dash

Reputation: 1513

0x80004005 A connection attempt failed because the connected party did not properly respond after a period of time

I am facing this problem while accessing web service from ASP.NET application.
But the problem occurs when it is hosted in a windows server.
When it is hosted in desktop it is working fine.
I am calling web service with HttpWebRequest object.

Even it is working fine in server from HTML/Java Script application. Only problem occurs in ASP.NET application hosted in server. I get following error. IIS 8.0 is installed in server.

Unable to connect to the remote server
System.Net.Sockets.SocketException (0x80004005): 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 153.2.228.76:443 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at VSPTestApplication.UPS.CalculateRate_Click(Object sender, EventArgs e)
System.IO.Stream GetRequestStream(System.Net.TransportContext ByRef) 

Upvotes: 3

Views: 11515

Answers (2)

user6911190
user6911190

Reputation:

I also faced the same issue, and got solved just by troubleshooting the network.

in windows-> settings -> Network & Internet -> Network Troubleshooter

Upvotes: 0

feroze
feroze

Reputation: 7594

Looking from your error message I notice that you are trying to hit a HTTPS url. This can be tricky when running in aspnet in IIS, because your code runs in a different user context. And the necessary certificates might not be installed in that context. For eg, if the target server has a certificate signed by a CA that is not trusted by the client's machine (asp.net/iis/windows) then the request wont succeed.

However, a certificate error would manifest clearly. it wouldnt show up as a failure to connect.

I suggest using system.net logging facility to create a logfile. That should help troubleshoot the problem. Also, you should run wireshark on the windows server and see where the server is trying to connect. It might be as simple as that the windows server does not have connectivity to the target. Or there might be a proxy in middle that is screwing up the network path.

To setup system.net logging, you can put the following config file in the same directory as the app that is running your code.

<?xml version="1.0" encoding="UTF-8" ?>

<configuration>
<system.diagnostics>
<trace autoflush="true" />

<sources>
<source name="System.Net">

<listeners>
    <add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
    <add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Cache">
<listeners>
    <add name="System.Net"/>
</listeners>
</source>
</sources>
<sharedListeners>
    <add
        name="System.Net"
        type="System.Diagnostics.TextWriterTraceListener"
        initializeData="System.Net.trace.log"
    />
</sharedListeners>
<switches>
    <add name="System.Net" value="Verbose" />
    <add name="System.Net.Sockets" value="Verbose" />               
    <add name="System.Net.Cache" value="Verbose" />
</switches>

for more details on logging:

creating a tracelog with system.net

Upvotes: 0

Related Questions