10分钟后,WCF回调服务与netTcp绑定超时(WCF Callback Service with

2019-06-23 15:39发布

我创建与WCF(使用回调契约)和NetTcpBinding的聊天应用。 我托管服务作为Windows服务,并通过客户端应用程序从其他计算机访问它。

那我现在面临的问题是后10分钟,这似乎是某种超时发生的客户端的连接涉及到一个故障状态。 我已经尝试过增加接收超时和两个服务端和客户端发送超时,但没有奏效。

其设置应我改变,以增加该超时周期和保持应用程序,服务或客户端?

以下是我的配置文件,

服务

    <system.serviceModel>
    <services>
      <service behaviorConfiguration="PeerTalk.Service.ChatServiceBehavior"
        name="PeerTalk.Service.ChatService">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="PeerTalk.Service.ServiceContracts.IChat">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:7920/ChatService" />
            <add baseAddress="net.tcp://localhost:7921/ChatService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="PeerTalk.Service.ChatServiceBehavior">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="tcpBinding"
                 maxBufferSize="67108864"
           maxReceivedMessageSize="67108864"
           maxBufferPoolSize="67108864"
           transferMode="Buffered"
           closeTimeout="00:01:00"
           openTimeout="00:01:00"
           receiveTimeout="00:00:10"
           sendTimeout="00:00:10"
           maxConnections="100">
          <readerQuotas maxDepth="64"
                        maxStringContentLength="67108864"
                        maxArrayLength="67108864"
                        maxBytesPerRead="67108864"
                        maxNameTableCharCount="16384"/>
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows"/>
          </security>
          <reliableSession enabled="false" inactivityTimeout="00:01:00"/>

        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

客户

<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_IChat" closeTimeout="00:01:00" openTimeout="00:01:00"
          receiveTimeout="00:10:00" sendTimeout="00:00:10" transactionFlow="false"
          transferMode="Buffered" transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="67108864"
          maxBufferSize="67108864" maxConnections="10" maxReceivedMessageSize="67108864">
          <readerQuotas maxDepth="32" maxStringContentLength="67108864"
            maxArrayLength="67108864" maxBytesPerRead="67108864" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:01:00"
            enabled="false" />
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <client>     
          <endpoint address="net.tcp://10.10.10.45:7921/ChatService" binding="netTcpBinding"
               bindingConfiguration="NetTcpBinding_IChat" contract="PeerTalkService.IChat"
               name="NetTcpBinding_IChat">
          </endpoint>
    </client>
  </system.serviceModel>

谢谢。

Answer 1:

在这种情况下,超时是由两个限定receiveTimeout在结合和inactivityTimeout其用于双工消息在可靠的会话。 正确的解决方案是不增加超时,但实施一些平/保活消息。 其原因是增加超时将保持打开状态,失败的客户。



Answer 2:

你可以发布客户端调用示例(服务呼叫例子)。 什么可能发生在这里的是你没有正确关闭客户端和您接触服务端最大会话。
你必须意识到,使用net.tcp绑定是不是http不同。

您可以使用System.ServiceModel性能计数器(http://msdn.microsoft.com/en-us/library/ms750527.aspx),10分钟发生了什么(来电突出,服务实例的数量,数量等后见。)

http://dkochnev.blogspot.com/2011/06/wcf-framework-40-monitoring-service.html



文章来源: WCF Callback Service with netTcp Binding timeout after 10 mins