kumar jane

kumar jane

  • NA
  • 1
  • 1.6k

Error : The underlying connection was closed.

Feb 15 2013 5:59 AM
Hello Friends,

I am sending 5 sms from my asp.net application in c# at a time using HttpWebRequest. Its running fine but sometimes sms sending fails becoz of this error:

Error : The underlying connection was closed: An unexpected error occurred on a receive.

Code for sending sms:
I tried webreq.KeepAlive = true; but still it doesn't work...

------------------------------------------------------------------------------------------------------------------
Page curent = new Page(); string SmsUrl = url + parameter; HttpWebRequest webreq = WebRequest.Create(SmsUrl) as HttpWebRequest; webreq.ContentType = "application/x-www-form-urlencoded";//"text/html; charset=UTF-8"; webreq.Method = "POST"; byte[] bytes = Encoding.ASCII.GetBytes(parameter); webreq.Timeout = 10000000; webreq.KeepAlive = true; Stream os = null;

WebResponse webresponce = webreq.GetResponse();
if (webresponce == null)
{
return null;
 }
 StreamReader sr = new StreamReader(webresponce.GetResponseStream());
 res = sr.ReadToEnd();
 Console.WriteLine(res);
 return res;
---------------------------------------------------------------------------------------------------------------------

Please advice something...

Answers (1)