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: , ,

8 Comments:

Anonymous Anonymous 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  
Anonymous Anonymous 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 Anonymous said...

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

8:55 PM  
Anonymous Anonymous 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 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  
Blogger Delhi Escorts said...

I am Swati Loomba; use to write blogs and experience of my independent call girls. I am from Delhi. I have my own Independent Escorts in Delhi. People really want to change their life and have fun. So we are here to give them immense pleasure and enjoyment. Give yourself a break from hectic life. Opt for an escort service that you never felt before.

1:50 PM  

Post a Comment

<< Home