2011-06-08 43 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