Welcome to AddressOf.com Sign in | Join | Help

Web Service Woes (A light at the end of the tunnel?)

Well, I just couldn't let this go... so even more searching on google and yet more trying this or that to see if I could get past this issue.  I figured I'd try to use async calls using the two methods in the help as examples.  Neither one of those made any difference.  Besides, I really didn't want to have to sit on hold with Microsoft Support ;-)

I finally broke down and used Fiddler to look at the packets... everything looks good with those.  So at least now I can say, yes, I tried that as well.

After much more searching, I found out how to modify the Keep-Alive setting inside of a Web Service call.  It's a serious hack in my opinion and apparently has other issues surrounding authentication models (Windows/NTLM); but if it fixes my problem, I really don't care at this point.  (Note: According to some of what I came across, when using Windows/NTLM authentication, it looks like the connection is reset after each call???, so having Keep-Alive enabled might not be an issue in this case?)  Also, if this fixes the problem, then this definitely looks like a serious bug in the FCL and should be corrected... in my opinion way before the Whidbey release time frame.  There's a lot of code that is being deployed under .NET 1.1 and will probably continue to do so for some time beyond the release of Whidbey.  Considering Web Services are arguably one of the most important technologies in .NET; this kind of error occurring is downright unacceptable.

Basically, you have to view the code that was generated via the add web service method in VS.NET.  Once you are in there, add the following override:

Protected Overrides Function GetWebRequest(ByVal uri As System.Uri) As System.Net.WebRequest

  Dim webRequest As Net.HttpWebRequest = CType(MyBase.GetWebRequest(uri), Net.HttpWebRequest)

  webRequest.KeepAlive = False

  Return webRequest

End Function

This will modify the web service connection so that Keep-Alive is disabled.  So far this has worked in my small test application... running for over 8 minutes.  All previous tests have always failed between 5-6 minutes.  I've modified my real application, reversing many of the changes that I've attempted in the past to revert the code back to it original state and it's running right now as a test.

Note: Beth in the original Web Service Woes entry mentioned trying to turn off HTTP Keep-Alive on IIS, but since I don't have control over that server (shared hosting), that was not an option.  I'm not sure who Beth is (no address left), but if you read this, thanks for the information; it looks like that might be the problem based on initial testing.

Although everything that I've found on Keep-Alive and Web Service wasn't related to the problem that I'm having, I figured I'd give it a shot based on what Beth stated.  While writing this, the application in question has been running successfully for over 20 minutes for the first time in over three weeks (possibly longer).  Not wanting to get my hopes up to high, but I just can't help it ;-)

Keeping fingers crossed.

Published Tuesday, April 27, 2004 2:57 AM by CorySmith
Filed under:

Comments

# re: Web Service Woes (A light at the end of the tunnel?)

Friday, October 15, 2004 11:29 AM by Mike Faulkinbury
Perfect! This works.

The only change that I would suggest is to create a new class that derives from the auto-generated proxy class, so that your code doesn't get "wiped out" if you choose "Update Web Reference" later.

Namespace com.mydomain.www
Public Class SafeWebService1
Inherits WebService1

' your code here

End Class
End Namespace

# re: Web Service Woes (A light at the end of the tunnel?)

Friday, October 15, 2004 12:17 PM by Cory Smith
Sometimes the simplest solution are the most elusive ;-)

Thanks for the great suggestion.

# re: Web Service Woes (A light at the end of the tunnel?)

Sunday, June 05, 2005 7:09 PM by nick
thank god - this worked for me too - i was going insane.

# re: Web Service Woes (A light at the end of the tunnel?)

Tuesday, September 20, 2005 6:45 PM by Scott Taylor
I'm having major problems and I think it's similar to this...

Can you throw me an email?

staylor @ eapexpert dot com

# re: Web Service Woes (A light at the end of the tunnel?)

Monday, October 31, 2005 10:17 AM by Fabio Xodo
You just saved me!
Thank you

# re: Web Service Woes (A light at the end of the tunnel?)

Tuesday, November 15, 2005 9:15 AM by Loris
thanks, works here! I whish I had found this page two months ago....

# re: Web Service Woes (A light at the end of the tunnel?)

Wednesday, February 01, 2006 12:34 PM by adi
Finally the right solution for this matter. Good job!

# Any Drawbacks?

Tuesday, December 05, 2006 7:51 AM by Daniel Bryars

Are there any significant drawbacks to disabling keep alive? I have the same problem but luckily quite infrequently; my clients suffer the error once or twice a day, and I use a retry scheme to deal with them.

I presume that without keep alives that there's more overhead for the server? Or is a Web Service call a single request / response?

Anonymous comments are disabled