Tracking CoreWCF Issue 1643 - Linux WebSocket bug in Close method
- Dominant language
- C#
- Stars
- 1.8k
- Forks
- 576
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 2
Description
**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: https://github.com/CoreWCF/CoreWCF/issues/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: https://github.com/dotnet/wcf/pull/5802
```C#
// 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](https://github.com/dotnet/wcf/pull/5802/files#diff-c962654ed47f85e033f77c3dcfdf7253c29b42e945339474f6a10d195323de2b) once https://github.com/CoreWCF/CoreWCF/issues/1634 is resolved, as below:
```C#
((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):
Contributor guide
Assessment
This issue has not been assessed yet.