none
Communication channel aborted error when application remains idle for sometime RRS feed

  • Question

  • Could someone please assist here?

    In my application we have used client server architecture.

    Client and server communicates using wcf services.

    If client application is kept idle for sometime application hangs.

    I could see below error in event viewer logs.

    The communication object, System.ServiceModel.Security.SecuritySessionServerSettings+SecurityReplySessionChannel, cannot be used for communication because it 
    has been Aborted.
    
       at System.ServiceModel.Channels.CommunicationObject.ThrowIfClosedOrNotOpen()
       at System.ServiceModel.Security.SecuritySessionServerSettings.ServerSecuritySessionChannel.SecureApplicationMessage(Message& message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState)
       at System.ServiceModel.Security.SecuritySessionServerSettings.SecuritySessionRequestContext.OnReply(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.RequestContextBase.Reply(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.RequestContextBase.Reply(Message message)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc& rpc)
    
    **** client exception : : System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: The message could not be processed. This is most likely because the action 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT/Cancel' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.
       --- End of inner exception stack trace ---
    
    Server stack trace: 
       at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.ProcessRequestContext(RequestContext requestContext, TimeSpan timeout, SecurityProtocolCorrelationState correlationState)
       at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.ReceiveInternal(TimeSpan timeout, SecurityProtocolCorrelationState correlationState)
       at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.CloseOutputSession(TimeSpan timeout)
       at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.CloseSession(TimeSpan timeout, Boolean& wasAborted)
       at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnClose(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnClose(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)

    Please advise.

    Friday, October 27, 2017 11:56 AM

All replies

  • Normally, when the WCF service returns control back to the client, then the client is supposed to close he connection.

    This is happening I would assume.

    Saturday, October 28, 2017 6:11 PM
  • Hi Rajesh,

    >> If client application is kept idle for sometime application hangs

    What do you mean by this?

    Based on the error message, it seems the connection has been closed by Server side.

    Could you add Try Catch block to capture this error and then reopen the connection to run next action?

    It would be helpful if you could share us a simple demo which could reproduce your issue.

    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.

    Monday, October 30, 2017 2:05 AM
  • Hi Edward,

    I have written WCF service and consumed that in another windows application.

    If I keep the application (application where I am consuming WCF service) idle for sometime and tries to do some operation after sometime then application becomes unresponsive.I have to close application using task manager.

    That is what i mean by 'client application is kept idle for sometime application hangs'.

    Please advise where exactly should I add try catch block?

    Thank you so much.

    Monday, October 30, 2017 11:54 AM
  • The WCF Web service is taken out of scope if sits idle on the Web server, it has to be recompiled and put back into scope.
    Monday, October 30, 2017 5:59 PM
  • Hi Rajesh,

    >>If I keep the application (application where I am consuming WCF service) idle for sometime and tries to do some operation after sometime then application becomes unresponsive.

    Did the windows application become unresponsive before doing other operations or after doing the other operations?

    If it happens during waiting, I assume your windows application is blocked and becomes unresponsive. If so, I think you could try start a new thread to take WCF operations.

                var task = Task.Factory.StartNew(() => {
                    //WCF Client code
                });

    If it did not work, if would be helpful if you could share us a simple project which could reproduce your issue.

    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.

    Tuesday, October 31, 2017 1:40 AM