There are too many active security negotiations or secure conversations at the service.
I was fighting an error today. It might show itself as
- There are too many active security negotiations or secure conversations at the service.
- The operation has timed out
- SecurityNegotiationException
Conditions for making it happen
- In WCF (Windows Communication Foundation)
- Your clients open and close connections to the server without calling any method
- You protect your service with some kind of security
- You have at least 128 security negotiations in 2 minutes time
Why does it happen?
There is a bug #499859 that WCF does not remove a security session from the list of pending sessions when a client opens and closes a connection without calling any operations. The is room for 128 security session in the pending sessions queue and a security session times out in 2 minutes.
Possible fixes
I've come up with the following solutions.
Best solution would be to make your code stop open/close connections without calling any operations.
Increase the pending sessions queue length
If you can't fix the problem with open/closing connections you could make the problem less critical by increasing the pending sessions queue length. This you do by creating a custom binding.
Then you refer to this custom binding from your endpoint like this.
Hope this will help someone along the way. My main inspiration was this forum thread.