websocket-client icon indicating copy to clipboard operation
websocket-client copied to clipboard

Test OnClose_ShouldWorkCorrectly don't pass

Open gstester opened this issue 5 years ago • 3 comments

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

gstester avatar Feb 04 '20 11:02 gstester

Hello @gstester ,

thanks for the message. I got everything green: image

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

Marfusios avatar Feb 04 '20 13:02 Marfusios

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);

david-au avatar Feb 27 '20 09:02 david-au

Hello @david-au,

thanks for the message, let me check it, I will try to change it into more deterministic flow.

Marfusios avatar Feb 27 '20 15:02 Marfusios