2011-03-01 39 views
0

我有一個Silverlight客戶端,它試圖創建一個會話,但服務器沒有響應(客戶端拋出超時異常)。在服務器日誌中,我發現:WCF輪詢雙工會話

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"> 
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"> 
<EventID>0</EventID> 
<Type>3</Type> 
<SubType Name="Warning">0</SubType> 
<Level>4</Level> 
<TimeCreated SystemTime="2011-03-01T15:47:17.3951653Z" /> 
<Source Name="System.ServiceModel.PollingDuplex" /> 
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /> 
<Execution ProcessName="w3wp" ProcessID="3820" ThreadID="17" /> 
<Channel /> 
<Computer>VM662</Computer> 
</System> 
<ApplicationData> 
<TraceData> 
<DataItem> 
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning"> 
<TraceIdentifier>http://msdn.microsoft.com/ru-RU/library/System.ServiceModel.PollingDuplex.ListenerClosed.aspx</TraceIdentifier> 
<Description>The service no longer accepts new sessions. An http error was returned.</Description> 
<AppDomain>/LM/W3SVC/1/ROOT-1-129434680323302677</AppDomain> 
<Source>System.ServiceModel.Channels.PollingDuplexChannelListener/40535505</Source> 
<ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/PollingDuplexTraceRecord"> 
<clientAddress>http://docs.oasis-open.org/ws-rx/wsmc/200702/anonymous?id=1a9b0998-7fa0-4c53-8268-d4db5e8fad61</clientAddress> 
<serverAddress>http://porn.com/getgirls.svc</serverAddress> 
<sessionId>3d21efa1-1204-433a-8881-06cd6da7de60</sessionId> 
<HttpStatusCode>NotFound</HttpStatusCode> 
</ExtendedData> 
</TraceRecord> 
</DataItem> 
</TraceData> 
<System.Diagnostics xmlns="http://schemas.microsoft.com/2004/08/System.Diagnostics"> 
<LogicalOperationStack></LogicalOperationStack> 
<Timestamp>2545401989404</Timestamp> 
</System.Diagnostics> 
</ApplicationData> 
</E2ETraceEvent> 

這是什麼意思?爲什麼具有輪詢雙工綁定的WCF服務不能「接受新會話」?

更新: 服務器有大約20個併發會話請求,其中大多數失敗。但是當我開始另一次測試時,一切都很好。這個問題偶爾會發生,重啓服務器通常會解決這個問題。 服務器配置:

<system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel.PollingDuplex" switchValue="Information"> 

      <listeners> 

       <add type="System.Diagnostics.DefaultTraceListener" name="Default"/> 

       <add name="ServiceModelTraceListener" /> 
       <add name="ServiceModelMessageLoggingListener" /> 

      </listeners> 
     </source> 
     <!--<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing"> 
      <listeners> 
       <add type="System.Diagnostics.DefaultTraceListener" name="Default"/> 
       <add name="ServiceModelMessageLoggingListener"/> 
      </listeners> 
     </source> 
     <source name="System.ServiceModel" switchValue="Warning, ActivityTracing" propagateActivity="true"> 
      <listeners> 
       <add type="System.Diagnostics.DefaultTraceListener" name="Default"/> 
       <add name="ServiceModelTraceListener"/> 
      </listeners> 
     </source>--> 
    </sources> 
    <sharedListeners> 
     <add initializeData="c:\pdt_logs\messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelMessageLoggingListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp" /> 
     <add initializeData="c:\pdt_logs\web_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp" /> 
    </sharedListeners> 
    <trace autoflush="true" /> 
</system.diagnostics> 

<system.web> 
    <compilation targetFramework="4.0" /> 
</system.web> 

<system.serviceModel> 
    <diagnostics> 
     <messageLogging logEntireMessage="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" /> 
    </diagnostics> 
    <extensions> 
     <bindingElementExtensions> 
      <add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexElement, System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 
     </bindingElementExtensions> 
    </extensions> 

    <bindings> 
     <customBinding> 
      <binding name="PollingDuplexBinding" > 
       <binaryMessageEncoding> 
        <readerQuotas maxArrayLength="16777216" maxBytesPerRead="16777216" maxDepth="16777216" 
              maxNameTableCharCount="16777216" maxStringContentLength="16777216"/> 
       </binaryMessageEncoding> 
       <pollingDuplex maxPendingSessions="100" 
      maxPendingMessagesPerSession="250" inactivityTimeout="24.20:31:23.6470000"/> 

       <httpTransport maxBufferSize="16777216" 
           maxReceivedMessageSize="16777216" /> 
      </binding> 
     </customBinding> 



    </bindings> 

    <services> 
     <service name="PollingDuplexApplication.Services.TestService" behaviorConfiguration="ServiceBehavior"> 
      <endpoint address="" 
           binding="customBinding" 
           contract="PollingDuplexApplication.Services.TestService" 
           bindingConfiguration="PollingDuplexBinding"> 
      </endpoint> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 

    <behaviors> 
     <serviceBehaviors> 
      <behavior name="ServiceBehavior"> 
       <serviceMetadata httpGetEnabled="true"/> 
       <serviceDebug includeExceptionDetailInFaults="true"/> 
       <serviceThrottling maxConcurrentCalls="2048" maxConcurrentSessions="2048" maxConcurrentInstances="2048"/> 
       <dataContractSerializer maxItemsInObjectGraph="16777216"/> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

+0

你有多少個併發客戶端,服務器上運行了多少個會話,你的服務限制配置是什麼? – 2011-03-01 16:04:50

+0

請看我的更新。 – 2011-03-01 16:11:11

+0

嘗試使用許多不同的物理計算機作爲客戶端。不是每個客戶端在同一臺機器上... – 2012-08-17 15:28:23

回答

0

什麼輪詢雙工模式是您使用?我遇到了類似的問題,其中服務器遇到了多個消息的問題。

解決方案是將我的PollingDuplexMode更改爲SingleMessagePerPoll。看起來WCF對於MultipleMessagesPerPoll有一些問題。

而構建綁定可以改變模式:

new PollingDuplexHttpBinding(PollingDuplexMode.SingleMessagePerPoll); 

或者在配置文件中。

0

想到兩件事情,我應該注意到我沒有用Silverlight做這個,只有普通的WCF。可以激活的併發會話數有限制。這個限制是16我相信開箱即用。你可以看到如何改變它在這個答案

WCF Concurrent requests piling up on the server when using WSHttpBinding

,或者你可以在SVC文件編輯器改變它。如果你用代碼來定義你的服務器,你需要在綁定中找到這個選項,並且我不記得那是否在我的頭頂。

您也可能在服務器上備份。我會建議(在檢查你的鎖定模型後)將服務合約標記爲併發=多個