WCF "Too Many Active Security Negotiations" Production Mistake

We have a WCF service, which is called by more than 100 client sites. Today we started to get

Exception: Server 'http://[url]/services/[service].svc/ws' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. System.ServiceModel.FaultException: There are too many active security negotiations or secure conversations at the service. Please retry later. 

The only information I could find is that I need to make maxPendingSessions bigger. But this will require changing the endpoint to CustomBinding, which will be difficult because I would have to click this on all of my client sites.

Is there a way that I can simply "reset" the number of security negotiations, etc.? This will give us time to change the client program to use user binding, because at the moment our sites cannot talk to our server.
I tried to make a small change to the configuration file and save that it was supposed to restart the service, but we still get errors.

Or is there any other way to handle this?

Edit Here is my configuration:

 <?xml version="1.0"?> <configuration> <configSections> <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/> </configSections> <connectionStrings> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0"/> <authorization> <allow users="?"/> </authorization> </system.web> <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="Error" propagateActivity="true"> <listeners> <add name="xml" /> </listeners> </source> </sources> <sharedListeners> <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="D:\logs\log.txt" /> </sharedListeners> </system.diagnostics> <system.serviceModel> <diagnostics performanceCounters="All" /> <services> <service name="WCFServiceLibrary.WCFService"> <endpoint address="ws" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWCFService" name="WSHttpEndpoint_IWCFService" contract="WCFServiceLibrary.IWCFService" /> <endpoint address="basic" binding="basicHttpBinding" name="BasicHttpEndpoint_IWCFService" contract="WCFServiceLibrary.IWCFService" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IWCFService" maxBufferPoolSize="524288" maxReceivedMessageSize="1048576"> <readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="Message"> <message clientCredentialType="Certificate" negotiateServiceCredential="true" algorithmSuite="Default" /> </security> </binding> </wsHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior> <serviceCredentials> <serviceCertificate findValue="CN=[url]" storeLocation="LocalMachine" storeName="TrustedPeople" /> <clientCertificate> <authentication revocationMode="NoCheck" certificateValidationMode="PeerTrust" /> </clientCertificate> </serviceCredentials> <serviceThrottling maxConcurrentCalls ="1001" maxConcurrentSessions="1001" maxConcurrentInstances="1000" /> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> </system.serviceModel> </configuration> 

EDIT
We tried iisreset and even restarted the server, and it still threw the same error.

+6
source share
2 answers

http://social.msdn.microsoft.com/Forums/en-GB/wcf/thread/a8f82f1d-e824-474e-84ef-b5e9ba7eca18

The problem is creating the client, but not using it (without calling any method on it).

http://litemedia.info/there-are-too-many-active-security-negotiations-or-secure-conversations-at-the-service

I spent 4 days researching this in .NET 4.0 to realize that it is NOT fixed.

Repro is easy:

 ChannelFactory<IFoo> foo = new ChannelFactory<IFoo>("binding"); foo.Open(); foo.Close(); 

After 128 calls, you will receive an error message.

I do not know why this is not fixed, but the solution is to create a proxy server when you are sure that you need to call it. Increasing maxPending noy is really useful since you can still get into threashold.

+3
source

Since it seems that you are not using a custom factory service, you are not creating a single-user service hosted in IIS. The problem may be with configuring the service for multi-threaded processing. If your service does not contain code that depends / controls multiple threads, you must configure the service to be single-threaded. Set ConcurrencyMode = Single and remove the serviceThrottling element from the configuration to use the built-in default values ​​for WCF. If the exceptions disappear, then everything is ready. Otherwise, you will find out that this is not a multi-threaded configuration or service throttling settings.

0
source

Source: https://habr.com/ru/post/890085/


All Articles