WCF Fails Under Load - MessageSecurityException
-
19-08-2019 - |
Question
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?
Solution 3
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.
OTHER TIPS
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
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.