2013-05-14 52 views
0

我們有一個系統,客戶端Flash應用程序正在調用基於asmx的搜索Web服務,該服務使用NetTcpBinding調用託管在Windows服務中的wcf服務。這是工作正常時,沒有。的搜索結果很小。當返回的郵件很大時,WCF呼叫超時

`The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.` 

爲了排除錯誤,我們啓用服務跟蹤和:但是,當搜索結果會大,在2000年記錄的範圍,我們在那裏調用WCF湊了ASMX服務異常發現報告的錯誤是:

`The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:00'.` 

我們增加了在服務器和客戶端CONFIGS超時值還增加了maxItemsInObjectGraph值。在wcf調用中沒有發生錯誤,因爲我們可以調試它,並且觀察到的行爲是,當wcf調用返回時,asmx服務中的代碼正在觸發異常塊並報告上述錯誤。

服務器端配置:

<system.serviceModel> 
<services> 
    <service name="***.SearchController" behaviorConfiguration="serviceBehavior"> 
    <endpoint address="net.tcp://localhost:8228/SearchController" binding="netTcpBinding" contract="***.ISearch" name="SearchController" /> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="serviceBehavior"> 
     <serviceDebug includeExceptionDetailInFaults="True" /> 
     <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<bindings> 
    <netTcpBinding> 
    <binding name="LargeMessageBinding" 
      maxBufferPoolSize="2147483647" 
      maxBufferSize="2147483647" 
      maxConnections="2147483647" 
      maxReceivedMessageSize="2147483647" 
      portSharingEnabled="false" 
      transactionFlow="false" 
      listenBacklog="2147483647" 
      closeTimeout="infinite" 
      openTimeout="infinite" 
      receiveTimeout="infinite" 
      sendTimeout="infinite"> 
     <security mode="None"> 
     <message clientCredentialType="None"/> 
     <transport protectionLevel="None" clientCredentialType="None"/> 
     </security> 
     <reliableSession enabled="false"/> 
     <readerQuotas maxDepth="2147483647" 
     maxStringContentLength="2147483647" 
     maxArrayLength="2147483647" 
     maxBytesPerRead="2147483647" 
     maxNameTableCharCount="2147483647" /> 
    </binding> 
    </netTcpBinding> 
</bindings> 
<diagnostics wmiProviderEnabled="true"> 
    <messageLogging 
     logEntireMessage="true" 
     logMalformedMessages="true" 
     logMessagesAtServiceLevel="true" 
     logMessagesAtTransportLevel="true" 
     maxMessagesToLog="3000" 
    /> 
</diagnostics> 
<client></client> 

客戶端(axms)端配置:

<system.serviceModel> 
    <client> 
    <endpoint address="net.tcp://localhost:8228/SearchController" binding="netTcpBinding" behaviorConfiguration="endpointBehavior" contract="***.ISearch" name="NewSearch"/> 
</client> 
    <bindings> 
    <netTcpBinding> 
    <binding name="LargeMessageBinding" 
      maxBufferPoolSize="2147483647" 
      maxBufferSize="2147483647" 
      maxConnections="2147483647" 
      maxReceivedMessageSize="2147483647" 
      portSharingEnabled="false" 
      transactionFlow="false" 
      listenBacklog="2147483647" 
      closeTimeout="infinite" 
      openTimeout="infinite" 
      receiveTimeout="infinite" 
      sendTimeout="infinite"> 
     <security mode="None"> 
     <message clientCredentialType="None"/> 
     <transport protectionLevel="None" clientCredentialType="None"/> 
     </security> 
     <reliableSession enabled="false"/> 
     <readerQuotas maxDepth="2147483647" 
     maxStringContentLength="2147483647" 
     maxArrayLength="2147483647" 
     maxBytesPerRead="2147483647" 
     maxNameTableCharCount="2147483647" /> 
    </binding> 
    </netTcpBinding> 
</bindings> 
<behaviors> 
    <endpointBehaviors> 
    <behavior name="endpointBehavior"> 
     <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
</system.serviceModel> 

使用該代碼的WCF被從ASMX服務名爲:

List<***.SearchResult> results; 
    using (var searchFactory = new ChannelFactory<***.ISearch>("NewSearch")) 
    { 
     Legacy.ISearch searchProxy = searchFactory.CreateChannel(); 
     results = searchProxy.Search(searchOption); 
    } 

This ca ll正在報告例外情況。

我們不確定爲什麼即使在配置中增加閾值後,我們仍然會遇到超時問題。難道這個服務沒有拿起我們的綁定配置,並使用一些默認配置值,從而拋出錯誤。不知道如果服務在運行時實際提取了我們的配置,驗證的方式是什麼。 需要幫助解決此問題。

回答

2

您必須使用綁定在你的應用程序,但你聲明只使用bindingConfiguration財產

<endpoint address="net.tcp://localhost:8228/SearchController" binding="netTcpBinding" contract="***.ISearch" name="SearchController" bindingConfiguration="LargeMessageBinding" /> 

bindingConfiguration="LargeMessageBinding"到客戶端的配置也

+0

請考慮增加一些解釋你的答案程序員的好處誰可能想知道*爲什麼這是解決方案。 – Tim 2013-05-14 16:19:54