Sunday, February 26, 2006

The underlying connection was closed: An unexpected error occurred on a receive. (Web Service)

We had a web service which was working without any problem for few months and suddenly last week it started to give the above mentioned error. Even though I found some similar threads on the web, nothing helped me to solve the problem.

After few hours of R&D I found a workable solution! Overriding the web service's proxy class fixed the error where I’ve created a new HttpWebRequest.

protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
//Get a new HttpWebRequest
System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(uri);
webRequest.KeepAlive = false;
return webRequest;
}

Labels: , ,

13 Comments:

Anonymous Ethan Strass said...

This seems to work for me. Thanks!
But I have no idea why it works. Is there any simple explaination?

4:13 AM  
Anonymous Anonymous said...

Can someone please post a VB version to this solution?

Thanks.

5:58 PM  
Blogger Patriot Fan said...

I still get the error. Some people get it, some don;t. Tried this code with now luck..

System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://www.digback.com/login.php?username=beta1&password=beta1pass");
request.KeepAlive = false;
//HttpWebRequest request = WebRequest.Create("http://www.digback.com/login.php?username=beta1&password=beta1pass");


WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());

string str = reader.ReadLine();

6:11 AM  
Anonymous J. Gary Ellison said...

Would someone please let me in on the secret of where this miracle code goes?

4:27 PM  
Anonymous Anonymous said...

HI ,
where to write this code ?
i've got the same problem , im using my web service , from my application .
where to write this cod ? on the web service cod or on the application cod ?

thanks in advance
ishay

7:19 PM  
Anonymous micaleel said...

The code is inserted in the application in a file Reference.cs

8:55 PM  
Anonymous QV said...

You should try to set webRequest.KeepAlive = false; this has work for me. For more details how to solve The underlying connection was closed.


http://connectionstringexamples.com/article.php?story=underlying-connection-closed

1:19 PM  
Blogger vfdvgf said...

if wow gold and maple story mesos wow gold

8:51 AM  
Blogger Rajeswor Shrestha said...

I had the same error a week ago and I found a solution here :

http://www.asp.net.nepalesemap.com/index.php?topic=12.0

There are several solutions for this. You can find the list of solutions here:

http://www.asp.net.nepalesemap.com/index.php?board=2.0

8:33 AM  
Anonymous Anonymous said...

One evening wow gold a man was wow cdkeys at home watching TV and eating peanuts.pet clothes He'd toss them in the air,wow power leveling then catch them RuneScape Gold in his mouth.world of warcraft power leveling In the middle of catching one, Eve isk his wife asked wow power leveling a question, maple story mesos and as he turned to answer her,flyff penya a peanut world of warcraft gold fell in his ear. He tried and tried maple story power leveling to dig it out but only world of warcraft gold succeeded in pushing cheap wow gold it in deeper pet clothingHe asked his wow Power Leveling wife for assistanceffxi gil and after hours of trying they flyff penya became worried and decided to go to hospital. As they were ready 2moons power leveling to go out the door, archlord power leveling their daughter archlord gold came home last chaos money with her date.

10:23 AM  
Blogger  said...

姫野愛MUTEKI吉野公佳鈴木早智子エロ動画YouTubeえろつべSEXエロ動画アダルトロリータMUTEKIおっぱいアダルトS1ニコニコ動画youtubeveohエロ動画ようつべエロ動画えろつべエロ動画SEXゆーちゅーぶ

東京ほっとアダルトH動画エロ動画JK・JCyoutubeエロ動画熟女ニコ動画S1エスワン無修正AV動画エロ動画ユーチューブYouTubeようつべAV無料パイパン近親相姦レイプ強姦中出し二宮沙樹パイズリ明日花キララ

6:32 PM  
Blogger  said...

オーラルセックス手こきパイパンイラマチオパイズリパイズリみひろ蒼井そら穂花原紗央莉小澤マリア初音みのりRio(柚木ティナ)秋元美由北条麻妃妃乃ひかりかすみ果穂天海つばさ藤浦めぐAV女優アダルトエロ動画JKアダルトまんこ

人妻奥様熟女熟女アダルト エロ動画マダムパンチラアダルトフェラフェラパイズリ手こき手こき痴女熟女熟女熟女熟女美脚美尻巨乳熟女巨乳

6:32 PM  
Anonymous Anonymous said...

アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト

2:12 PM  

Post a Comment

<< Home