none
Our service written in WCF (Proxy on the client) is showing exception as under lying connection is closed RRS feed

  • Question

  • We have a proxy (Client side) and Server we keep seeing error messages server under lying connection is closed . We checked the network connection and everything looks good but  happens on regular basis and we have some 70 clients connecting to our server. 


    On the code we handle exceptions and use retry the connection when exception happens. On config file of both server and client we use default binding time.

    Please help us how to avoid errors proxy and server .

    Thursday, February 16, 2017 7:39 PM

All replies

  • Hi Seetha,

    Do you mean only the specific one of 70 clients throw this error or all of clients throw this error regularly?

    To check detailed error message, I would suggest you enable Tracing at client and service side.

    You could refer the link below for more information.

    #Configuring Tracing

    https://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 17, 2017 2:08 AM
  • Hi Edward,

    Thanks for responding .

    It does not happen on particular client . Under lying connection closed issue happens on Random clients and we do not have access as it is hosted on client side. We also do logs but it is stored on the client side

    Server side log we have access but no use since we do not see any issue why it failed. 

    The database is not heavily used . We do async calls from proxy to server .  

    We also used trace log like you mentioned above but it was causing performance over head on server side.



    • Edited by Seetha Guru Tuesday, February 21, 2017 7:02 PM
    Tuesday, February 21, 2017 4:39 PM
  • Hi Seetha,

    >> On the code we handle exceptions and use retry the connection when exception happens.

    Will it work if you retry the connection?

    I am afraid it is difficult to identify the issue without checking Tracing log at client side, I would suggest you contact the issue client to get logs.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 22, 2017 5:45 AM
  • Well, you  may need to look at the inner.exception message to get the real error on a connection  is being closed.
    Thursday, February 23, 2017 1:04 AM
  • All we got from inner exception message is under lying connection is closed. Can you suggest best way of handling exceptions i mean time out exceptions, network connection exceptions etc. We are going to on trace on client side but if there are better way of handling exceptions please suggest. Any performance tool we can use . We have used Perfmon and noticed the CPU of WCF goes high like 80% sometimes .
    Thursday, March 9, 2017 9:25 PM
  • Before error handing, I think we need to know the root cause of the error.

    For performance tool, I suggest you try the suggestion from below link.

    #Is there a tool for load test socket programming Send/receive

    https://social.msdn.microsoft.com/Forums/azure/en-US/b43be7c7-3531-4bf5-af45-661da5d8896b/is-there-a-tool-for-load-test-socket-programming-sendreceive?forum=wcf

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 10, 2017 6:10 AM
  • Hi Edward ,

    We got trace file from Client and all we see mostly 

    System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, 

    The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.

    System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
    System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
    System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
    System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
    System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
    System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
    System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
    Proxy.Send(String requestID, String customerNumber, Int32 socketNumber, Byte[] data, Int32 length)
    Proxy.ReadCallback(IAsyncResult ar)
    System.Net.LazyAsyncResult.Complete(IntPtr userToken)
    System.Net.ContextAwareResult.CompleteCallback(Object state)
    System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    System.Net.ContextAwareResult.Complete(IntPtr userToken)
    System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
    System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
    System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

    Can you suggest how can get more info from Trace files . I have trace viewer it is not helping me much

    Tuesday, March 21, 2017 7:26 PM
  • Based on the error message, the connection is closed by server, I would suggest you enable Tracing at Service side instead of client side. I assume the Trace log from service side would give us more detailed information.

    In addition, could you share us how did you host your service and your service web.config?


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 23, 2017 4:42 AM
  • Thanks Edward. Client side its window service and server we hosted on IIS . Server side tracing did not give enough information. 
    Thursday, March 23, 2017 4:31 PM
  • Most WCF related exceptions are derived CommunicationExceptionIf you are not already doing so, you can also look at the IClientChannel events to monitor what happens with the connection.

    client.InnerChannel.Closed += OnChannelClosed;
    client.InnerChannel.Opening += OnChannelOpening;
    client.InnerChannel.Opened += OnChannelOpened;
    client.InnerChannel.Closing += OnChannelClosing;
    client.InnerChannel.Faulted += OnChannelFaulted;
    client.InnerChannel.UnknownMessageReceived += OnChannelUnknownMessageReceived;



    william xifaras

    Thursday, March 23, 2017 9:14 PM