views:

932

answers:

3

I am load testing my website. The site calls to a WCF service running on the same box using clientCredentialType="Windows". Everything works until I reach a certain load (which is not even very high), then I get the following error:

System.ServiceModel.Security.MessageSecurityException: The HTTP request was forbidden with client authentication scheme 'Anonymous'. ----> System.Net.WebException: The remote server returned an error: (403) Forbidden.

Upon each call I create a channel:

var proxy = (IClientChannel)channelFactory.CreateChannel();

On success, I close:

proxy.Close();

On error, I abort:

proxy.Abort();

Any ideas what's going on? What I can do to handle loads better? What to look for?

+1  A: 

Is your Service a Sessionful Service or do you not worry about keeping state between calls? If you don't have state, you may want to mark your service as a PerCall service. This will make sure that the service instance only exists when a client call is in progress.

Chapter 4 of Juval Lowy's excellent book "Programming WCF Services" 2nd Edition covers this topic.

The default is PerSession which may not be what you want.

Also, see this on MSDN: How To: Control Service Instancing

Terry Donaghe
A: 

Thanks Terry. No my service does not maintain state. I tried decorating my service class with:

[ServiceBehaviorAttribute(InstanceContextMode = InstanceContextMode.PerCall)]

No help. The failure point seems to be at about 4 concurrent calls.

Tim Scott
What kind of work is your WCF service doing? Another thing you can try is to mock out your service. Use the same interface, but have the actual service code do nothing. See if you have a similar problem. If not, in the service put some Thread.Sleep's to simulate stuff going on.
Terry Donaghe
That'll let us know if there's a problem in the way you have stuff set up or a problem with your service. Know what I mean?
Terry Donaghe
A: 

The problem was, argh, that I was running the test on my dev box, which is XP, which uses IIS 5, which has a limit of 10 connections.

Tim Scott