2011-06-08 80 views
6

我们有超过100个客户站点拨打电话的WCF服务。今天,我们开始收到WCF生产中的“太多主动安全协商”错误

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. 

我能找到的唯一信息是,我需要做的maxPendingSessions较大。但是这需要将端点更改为CustomBinding,这很困难,因为我必须将其推送到所有客户端网站。

有没有什么办法可以“重置”安全协商的次数等?这会让我们有时间更改客户端程序以使用自定义绑定,因为目前,我们的网站无法与我们的服务器通话。
我试过对配置文件进行一些小改动并保存,这应该会重新启动服务,但我们仍然遇到错误。

或者还有其他方法可以处理这个问题吗?

编辑这里是我的配置:

<?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> 

编辑
我们尝试过的iisreset,甚至重新启动服务器,它仍然抛出了同样的错误。

+0

听起来像你有一个单一的服务与某种会话约束。如果您在问题中提供有关服务合同设置和配置的信息,这将有所帮助。 – 2011-06-08 19:51:48

+0

@Sixto是的。它在IIS中托管。我已经添加了我的配置。 – Marcus 2011-06-08 20:01:18

+0

回收应用程序池将回答您的重置问题,但不能解决您的问题。 由于您使用的是证书,因此您的问题可能由您的应用以外的其他因素引起。您的CA设置如何? – 2011-06-08 20:04:43

回答

3

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

问题是创建客户端,但不使用它(不要求它的任何方法)。

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

我花了4天,调查这个.NET 4.0意识到这是不固定的。

摄制很简单:

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

后来电128你的错误。

我不知道为什么它不是固定的,但解决方案是当你确定需要调用它时创建代理。增加maxPending noy真的很有用,因为你可能仍然击中了threashold。

+0

如何在确定需要调用时创建“代理”?我遇到了同样的问题,你的帖子很有前途,但同时令人沮丧。 – Sam 2016-04-28 10:48:42

0

由于您似乎没有使用自定义服务工厂,因此您并未创建托管在IIS中的单件服务。这个问题可能与设置你的服务运行多线程有关。除非您的服务包含依赖/管理多个线程的代码,否则您应该将服务实例配置为单线程。设置ConcurrencyMode = Single并从配置中删除serviceThrottling元素以使用这些内置的WCF默认值。如果例外消失,那么你就完成了。否则,你会知道它不是多线程配置或服务限制设置。

+0

不会设置ConcurrencyMode = Single将我限制为一次一个呼叫?这不会很好地扩展,我不希望我的客户不得不等待其他人完成。 – Marcus 2011-06-09 15:59:47

+0

带有IIS的WCF和您在问题中提供的配置将为每个WCF会话启动一个服务实例(这完全是**独立于**会话)。这[MSDN文章](http://msdn.microsoft.com/en-us/library/ms733040.aspx)有WCF会话的详细概述。每个呼叫或每个会话的InstanceContextMode设置都是非常可扩展的。 ConcurrencyMode控制的是每个服务实例是否被允许为多线程。 – 2011-06-09 17:50:12