none
Net.Tcp error on WCF service RRS feed

  • Question

  • Hi,

    I am receiving this error on my WCF service that has net.tcp protocol enabled. As far as I can tell the service is working fine with every client request returning data as usual but on the server I am seeing this error logged every few hours. It's totally random and seems to come in sudden bursts. Looking through the forums somebody suggested increasing the receivetimeout that I did what helped alleviate it a bit but not completely. I would like to know if it's a real error that affects the client or just some sort of inactivity. How can it be handled on server ?

    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 '10675199.02:48:05.4775807'.

    Here is my server setting for the binding not sure where the socket timeout value is coming on the error. The client settings are dynamic from code and are all set to defaults.

    Please let me know if somebody has an idea on this as it is critical I have an explanation and a solution for this for deployment.

     <netTcpBinding>
                    <binding name="PortSharingBinding" closeTimeout="05:01:00" openTimeout="05:01:00" receiveTimeout="05:01:00" sendTimeout="05:01:00" maxConnections="50" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" portSharingEnabled="true" transactionFlow="false">

    Wednesday, June 19, 2013 4:10 PM

Answers

  • Hi,

    From research, one of the possible causes of this issue is channel faulted but not handled properly, please try use try-finally where you can call close on the client object and if the communication channel faulted you can call abort on the client object instead of calling your code inside a using statement.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, June 21, 2013 6:30 AM
    Moderator

All replies

  • Hi,

    >>Looking through the forums somebody suggested increasing the receivetimeout that I did what helped alleviate it a bit but not completely

    ReceiveTimeout is the idle timeout value during the period connection can remain, during which no application messages are received and this time period is bigger than the set value, then the server will drop the connection with the client actively, so do you try set it to a more larger value?

    And the error also can be caused by clients disconnection or abnormal disconnection. There is also a InactivityTimeout, which indicates the idle timeout value that in the case of the client and the server side has been disconnected, during inactive periods, if the time is bigger than the set value, then trigger an event; if you want the event be triggered immediately when clients disconnect or abnormal disconnection, so set inactivityTimout as small as possible.

    Reference: #Explaination of different timeout types       

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/84551e45-19a2-4d0d-bcc0-516a4041943d/explaination-of-different-timeout-types

    In addition, you can turn on WCF tracing to help to diagnose: http://msdn.microsoft.com/en-us/library/ms733025.aspx?ppud=4.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, June 20, 2013 2:24 AM
    Moderator
  • Hi Haixia,

    Thanks for the reply. I changed the ReceiveTimeout to "Infinite" but still getting this error every half an hour or so. I have also captured the WCF trace that shows this error happening at specific time but has the same error description as my post. This is the stacktrace and the only thing noticeable when I click on this message as it shows normal process using a thread and when gets an exception is a different threadid. Not sure what else can I look for in the trace.

    System.ServiceModel.Channels.SocketConnection.EndRead()
    System.ServiceModel.Channels.TracingConnection.EndRead()
    System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
    System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback()
    System.ServiceModel.Channels.SocketConnection.OnReceiveAsync(Object sender, SocketAsyncEventArgs eventArgs)
    System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncFailure(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
    System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
    System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

    Thursday, June 20, 2013 4:35 PM
  • Hi,

    From research, one of the possible causes of this issue is channel faulted but not handled properly, please try use try-finally where you can call close on the client object and if the communication channel faulted you can call abort on the client object instead of calling your code inside a using statement.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, June 21, 2013 6:30 AM
    Moderator
  • Hi Haixia,

    I do not call open explicitly in code. The channel factory is assigned at application startup(dependency inversion) and then a direct method call to the service when requested. On running a load test it started to give socket aborted errors followed by client timeouts. This is actually worse than I thought that it will impact the client with concurrent users. The maxreceivedsize is set to a maximum so not sure what other configuration I could change. Regarding your response on the fault if client 1 gets a fault and client 2 requests a service call will it not open a new channel ?

    Monday, June 24, 2013 4:35 PM
  • Hi,

    >>Regarding your response on the fault if client 1 gets a fault and client 2 requests a service call will it not open a new channel ?

    I am not test this on my side, as I mentioned above, you'd better put the code in the try-catch block to avoid the issue.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, June 25, 2013 12:30 PM
    Moderator
  • I was able to resolve the issue by closing the channel on every call created from the channel factory.

    I had to do a typecast on the service  ((ClientChannel) bagService).Close();

    Now the issue is that the throughput is the same as using http. The only reason I went TCP was to improve performance. What else could I do to improve it ?

    Wednesday, June 26, 2013 6:39 PM
  • Hi,

    From my knowledge, you can try changing these settings for TCP binding to improve the performance: serviceThrottling to highest; set maxItemsInObjectGraph to 2147483647; increase the values of listenBacklog, maxConnections, and maxBuffer.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, June 27, 2013 7:17 AM
    Moderator