none
WCF Server Socket Connection Aborted Using NetTcpBinding RRS feed

  • Question

  • I have a persistent WCF issue that I cannot seem to solve. I have a WCF Duplex publisher subscribe architecture. The client is a windows form application and the service is hosted in a windows service. A form implements the callback and uses a protected proxy class to assign an event handler when the channel is faulted so the client can reconnect.

    There are about 100 clients subscribing at any one time. The problem is that some clients stop receiving messages from the service. The faulted event handler never fires on the client and thus never reconnects. I enabled tracing on the server and client and the error is consistent on the server. It throws about 5 exceptions in a row. I cannot determine why the service throws. I take that I get a socket timeout "error code 247c" which is hex for 10060 tcp socket timeout. What could cause that? I'm guessing that this fault doesn't let the client know the channel has become faulted. I have checked that port 5000 is open. No firewall issues..... Please help.

    Here is the trace view from the last exception and the inner most node in the exception tree:

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

    Here is my client app.config:

    <system.serviceModel>
        <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://************:5000/ClientNotificationService/tcp"
        binding="netTcpBinding" bindingConfiguration="netTCPEndPoint"
        contract="NotificationService.ClientNotificationServiceService"
        name="netTCPEndPoint">
        <identity>
          <userPrincipalName value="" />
        </identity>
       </endpoint>
      </client>
    </system.serviceModel>

    And here is my service app.config:

    <system.serviceModel>

        <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://**********:5000/ClientNotificationService/tcp"
              binding="netTcpBinding" bindingConfiguration="BindingTimeout"
              name="netTCPEndPoint" contract="NotificationService.IClientNotificationService">
              <identity>
                <userPrincipalName value="" />
                <dns value="http://**********" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
              name="mexEndPoint" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://***********:3081/NotificationService/ClientNotificationService" />
              </baseAddresses>
            </host>
          </service>
        </services>
      </system.serviceModel>

    Friday, November 1, 2013 3:58 PM

Answers