Post

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:

1
2
3
4
5
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.

This post is licensed under CC BY 4.0 by the author.