Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当返回的消息较大时,WCF调用超时_Wcf_Wcf Binding - Fatal编程技术网

当返回的消息较大时,WCF调用超时

当返回的消息较大时,WCF调用超时,wcf,wcf-binding,Wcf,Wcf Binding,我们有一个系统,其中一个客户端flash应用程序调用一个基于asmx的搜索web服务,而该web服务又使用NetTcpBinding调用托管在windows服务中的wcf服务。当搜索结果的数量很小时,这种方法可以很好地工作。但当搜索结果越来越大,在2000条记录范围内时,我们在asmx服务中遇到了一个例外,它调用wcf: `The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used f

我们有一个系统,其中一个客户端flash应用程序调用一个基于asmx的搜索web服务,而该web服务又使用NetTcpBinding调用托管在windows服务中的wcf服务。当搜索结果的数量很小时,这种方法可以很好地工作。但当搜索结果越来越大,在2000条记录范围内时,我们在asmx服务中遇到了一个例外,它调用wcf:

`The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.`
为了排除错误,我们启用了服务跟踪,发现报告的错误为:

`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'.` 
我们增加了服务器和客户端配置中的超时值,还增加了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>
<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>

客户端(axms)配置:

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

用于从asmx服务调用wcf的代码:

List<***.SearchResult> results;
    using (var searchFactory = new ChannelFactory<***.ISearch>("NewSearch"))
    {
        Legacy.ISearch searchProxy = searchFactory.CreateChannel();
        results = searchProxy.Search(searchOption);
    }
列出结果;
使用(var searchFactory=newchannelfactory(“NewSearch”))
{
Legacy.ISearch searchProxy=searchFactory.CreateChannel();
结果=searchProxy.Search(searchOption);
}
此调用正在报告异常

即使在增加配置中的阈值之后,我们也不确定为什么会出现超时问题。可能是因为服务没有获取我们的绑定配置并使用一些默认配置值,因此抛出了错误。不确定如何验证服务是否在运行时实际获取了我们的配置。
需要帮助解决此问题。

您必须在应用程序中使用绑定,但仅声明绑定,请使用
bindingConfiguration
属性

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


和<代码> bdIdgStase=“Client MexEng绑定”< /C> >客户端配置也

请考虑对您的答案添加一些解释,以便了解可能是解决方案的程序员的好处。