1

我有一个似乎无法解决的持久性 WCF 问题。我有一个 WCF Duplex 发布者订阅体系结构。客户端是一个 Windows 窗体应用程序,该服务托管在 Windows 服务中。当通道发生故障时,表单实现回调并使用受保护的代理类分配事件处理程序,以便客户端可以重新连接。

任何时候都有大约 100 个客户订阅。问题是一些客户端停止接收来自服务的消息。故障事件处理程序永远不会在客户端上触发,因此永远不会重新连接。我在服务器和客户端上启用了跟踪,并且服务器上的错误是一致的。它连续抛出大约 5 个异常。我无法确定服务抛出的原因。我认为我得到了一个套接字超时“错误代码 247c”,它是 10060 tcp 套接字超时的十六进制。是什么原因造成的?我猜这个故障不会让客户知道通道已经出现故障。我检查了端口 5000 是否打开。没有防火墙问题.....请帮助。

这是最后一个异常和异常树中最内层节点的跟踪视图:

<InnerException><ExceptionType>System.Net.Sockets.SocketException, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond</Message><StackTrace>   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.SynchronizedMessageSource.SynchronizedAsyncResult`1.End(IAsyncResult result)
   at System.ServiceModel.Channels.FramingDuplexSessionChannel.EndReceive(IAsyncResult result)
   at System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(IAsyncResult result)
   at System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)
   at System.ServiceModel.Channels.SynchronizedMessageSource.SynchronizedAsyncResult`1.CompleteWithUnlock(Boolean synchronous, Exception exception)
   at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object state)
   at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
   at System.ServiceModel.Channels.StreamConnection.OnRead(IAsyncResult result)
   at System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
   at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)
   at System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.OnAsyncReadComplete(Object state)
   at System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback()
   at System.ServiceModel.Channels.SocketConnection.FinishRead()
   at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead)
   at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace><ExceptionString>System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond</ExceptionString><NativeErrorCode>274C</NativeErrorCode></InnerException></InnerException></InnerException></Exception>

这是我的客户端 app.config:

<system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true"
                     maxMessagesToLog="1000"
                     logMessagesAtServiceLevel="true"
                     logMalformedMessages="true"
                     logMessagesAtTransportLevel="true" />
    </diagnostics>
        <bindings>
      <netTcpBinding>
        <binding name="netTCPEndPoint"
                 closeTimeout="10:00:00"
                 openTimeout="10:00:00"
                 receiveTimeout="10:00:00"
                 sendTimeout="10:00:00"
                 listenBacklog="300"
                 maxBufferPoolSize="1048576"
                 maxBufferSize="524288"
                 maxConnections="300"
                 maxReceivedMessageSize="524288">
          <reliableSession inactivityTimeout="10:00:00" enabled="false" />
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
        <client>
   <endpoint address="net.tcp://ccccc.************:5000/ClientNotificationService/tcp"
    binding="netTcpBinding" bindingConfiguration="netTCPEndPoint"
    contract="NotificationService.ClientNotificationServiceService"
    name="netTCPEndPoint">
    <identity>
      <userPrincipalName value="" />
    </identity>
   </endpoint>
  </client>
</system.serviceModel>

这是我的服务 app.config:

<bindings>
  <netTcpBinding>
    <binding name="BindingTimeout"
              closeTimeout="10:00:00"
              openTimeout="10:00:00"
              receiveTimeout="10:00:00"
              sendTimeout="10:00:00"
              listenBacklog="1000"
              maxBufferPoolSize="10485760"
              maxBufferSize="5242880"
              maxConnections="1000"
              maxReceivedMessageSize="5242880">
      <reliableSession inactivityTimeout="10:00:00" enabled="false" />
      <security mode="Transport">
        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
        <message clientCredentialType="Windows" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="NotificationService.ClientNotificationServiceBehavior">
      <serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000"
          maxConcurrentInstances="1000" />
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service behaviorConfiguration="NotificationService.ClientNotificationServiceBehavior"
    name="NotificationService.ClientNotificationService">
    <endpoint address="net.tcp://xxxx.*******:5000/ClientNotificationService/tcp"
      binding="netTcpBinding" bindingConfiguration="BindingTimeout"
      name="netTCPEndPoint" contract="NotificationService.IClientNotificationService">
      <identity>
        <userPrincipalName value="" />
        <dns value="http://xxxx.*******" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
      name="mexEndPoint" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://xxxx.*******:3081/NotificationService/ClientNotificationService" />
      </baseAddresses>
    </host>
  </service>
</services>

谢谢你。

4

0 回答 0