websocket-client
websocket-client copied to clipboard
Test OnClose_ShouldWorkCorrectly don't pass
Hi,
just cloned your repo, compiled and tryed to run tests. There I see the test 'OnClose_ShouldWorkCorrectly' didn't pass.
VS 2019, netstandard2.0, Microsoft.NET.Sdk
Could you please look into this?
Regards Gerd
Hello @gstester ,
thanks for the message.
I got everything green:

Could you try it again? Those integration tests are very fragile, they dependent on Bitmex API. More accurate are unit tests that execute in-memory only. Also, build server executes them on every commit: https://travis-ci.org/Marfusios/websocket-client
Hi,
I just faced the same issue with that particular test as what @gstester mentioned. I see that when client.Stop(WebSocketCloseStatus.InternalServerError, "server error 500") is invoked, server will send back a "close" message soon after, which triggers the below section of code within the listen method of WebsocketClient. As can be seen, an additional DisconnectionInfo (type=ByServer) will then get passed out on top of the DisconnectionInfo of type=ByUser, thus making the overall disconnectionCount to go to 2, instead of the expected value of 1.
else if (result.MessageType == WebSocketMessageType.Close) { Logger.Trace(L($"Received close message")); var info = DisconnectionInfo.Create(DisconnectionType.ByServer, client, null); _disconnectedSubject.OnNext(info);
Hello @david-au,
thanks for the message, let me check it, I will try to change it into more deterministic flow.