Quantcast
Channel: CSharp Forum Latest Questions
Viewing all articles
Browse latest Browse all 32057

Error : The underlying connection was closed.

$
0
0
HelloFriends,

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.

Codefor 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...

Viewing all articles
Browse latest Browse all 32057

Trending Articles