Skip to content

Tracking CoreWCF Issue 1643 - Linux WebSocket bug in Close method #5818

@afifi-ins

Description

@afifi-ins

Describe the bug
When calling the Close() method on the client channel factory CommunicationObject, the resources are not being released as expected, leading to an exception on the wcf client side.
CoreWCF Issue: CoreWCF/CoreWCF#1634

To Reproduce
Steps to reproduce the behavior:

  1. Start SelfHostedCoreWCF service
  2. Run any WebSocket test on Linux such as WebSocket_Http_Duplex_Buffered
  3. The test should fail to close the communication object of the channel factory.

Expected behavior
To workaround the bug, we provide a temporary fix and avoid calling Close() on client channel factory for WebSocket tests. See PR: #5802

// Close the client and channel factory if not running on localhost. CoreWCF has a bug in Close method (on Linux).
if (!ScenarioTestHelpers.IsLocalHost())
{
    ((ICommunicationObject)client).Close();
    channelFactory.Close();
}

We need to revert the code changes in WebSocketTests.4.1.0.cs once CoreWCF/CoreWCF#1634 is resolved, as below:

((ICommunicationObject)client).Close();
channelFactory.Close();

Additional context
Stack log:
WebSocketTests.WebSocket_Http_Duplex_Buffered(messageEncoding: Mtom) [FAIL]
System.Net.WebSockets.WebSocketException : The WebSocket is in an invalid state ('Aborted') for this operation. Valid states are: 'Open, CloseReceived, CloseSent'
Stack Trace:
at System.ServiceModel.Channels.WebSocketHelper.ThrowCorrectException(Exception ex, TimeSpan timeout, String operation)
at System.Runtime.TaskHelpers.Wait(Task task, TimeSpan timeout, Action exceptionConverter, String operationType)
at System.ServiceModel.Channels.WebSocketTransportDuplexSessionChannel.CompleteClose(TimeSpan timeout)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.OnCloseAsync(TimeSpan timeout)
at System.ServiceModel.Channels.WebSocketTransportDuplexSessionChannel.OnCloseAsync(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.OnCloseAsyncInternal(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.System.ServiceModel.IAsyncCommunicationObject.CloseAsync(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnCloseAsync(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.OnCloseAsyncInternal(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.System.ServiceModel.IAsyncCommunicationObject.CloseAsync(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.CloseAsyncInternal(TimeSpan timeout)
at System.Runtime.TaskHelpers.WaitForCompletion(Task task)
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Close()
at System.ServiceModel.Channels.ServiceChannelProxy.System.ServiceModel.ICommunicationObject.Close()
/_/src/System.Private.ServiceModel/tests/Scenarios/Extensibility/WebSockets/WebSocketTests.4.1.0.cs(171,0):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions