Http Post Error: 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.

Http Post Error: 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.

Post by Deep » Fri, 10 Jul 2009 23:18:11


Hi all,

I am facing HTTP POST problem:

The following piece of code for Http Post works fine if i execute it
in Visual Studio 8.0 in an Console Application.
Whereas if i execute the same code in a window service it gave me
following error:

System.Net.WebException:Unable to connect to remote server.
System.Net .Sockets.SocketException: 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.

The code is as follows:

string url = "some url";
Uri uri = new Uri(url);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create
(uri);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Proxy = WebRequest.DefaultWebProxy;
request.Proxy.Credentials =
CredentialCache.DefaultCredentials;
try
{
using (Stream writeStream = request.GetRequestStream
())
{
UTF8Encoding encoding = new UTF8Encoding();
byte[] bytes = encoding.GetBytes("CA761232");
writeStream.Write(bytes, 0, bytes.Length);
}
}
catch (Exception ex)
{
Logger.Current.Error(ex.ToString());
}

string result = string.Empty;
try
{
using (HttpWebResponse response = (HttpWebResponse)
request.GetResponse())
{
using (Stream responseStream =
response.GetResponseStream())
{
using (StreamReader readStream = new
StreamReader(responseStream, Encoding.UTF8))
{
result = readStream.ReadToEnd();
}
}
}
Logger.Current.Info("Output recieved from service as:
" + result);
}
catch (Exception ex)
{
Logger.Current.Error("Error while receiving: " +
ex.Message);
Logger.Current.Error("Error: " + ex.StackTrace);
}

Please reply me as earliest as i had put a lot of head already in
that.....

Thanks in advance
Deepu
 
 
 

1. Could Not Connect To SMTP Host Connection Failed -- Software caused connection abort: connect

2. Host connect failed - destination host not responding

Hi all,

I have this error on one of our customer when they try to
send email to us, but I have no problem sending email to
them.

What can I suggest them to test, I spoke to them and they
say we need to check on our side.

If anyone of you have earlier got this problem and know
what is the problem and how to resolve it, pls help.


-------------

Host connect failed - destination host not responding

What should you do?

You can resend the undeliverable document to the
recipients listed above by
choosing the Resend button or the Resend command on the
Actions menu.

Once you have resent the document you may delete this
Delivery Failure
Report.

If resending the document is not successful you will
receive a new failure
report

Unless you receive other Delivery Failure Reports, the
document was
successfully delivered to all other recipients.

3. Host would occasionally fail to resolve A's rec.Help!

4. Could not open connection to host, on port 25: connect failed

5. open failed: connect failed: Connection refused

6. NT Remote Connection Client fails reconnect attempts fail after network error.

7. channel 3: open failed: connect failed: Connection refused

8. Failed attempts to connect a SQL Server 2000 DB using a CF 4.5 connection

9. SQL30082N Attempt to establish connection failed with security reason "24" ("USERNAME AND/OR PASSWORD INVALID").

10. SQL30082N Attempt to establish connection failed with security reason "24"

11. Error 792 - The L2TP connection attempt failed because security negociation timed out

12. psjob - Connection attempt failed. / Server execution failed

13. RPC Fault faultString="error" faultCode="Channel.Call.Failed" faultDetail="NetConnection.Call.Failed: HTTP: Failed"

14. Error 792: The L2TP connection attempt failed because security negotiation timed out