sacOO7 / SocketclusterClientDotNet

C# client for socketcluster framework in node.js
http://socketcluster.io/#!/
Apache License 2.0
69 stars 16 forks source link

Exceptions not handled during reconnect and setting Reconnect strategy equal to null causes null reference exception #25

Open ddslawson opened 5 years ago

ddslawson commented 5 years ago

https://github.com/sacOO7/SocketclusterClientDotNet/blob/95332be2ee06f771229ccc506124fe9677c8bd5f/ScClient/Socket.cs#L225

I experienced an exception being thrown during the reconnect procedure. Specifically the exception said an attempt to connect was refused because an attempt to connect was already in progress. I believe some exception handling is needed on line 225 referenced above.

https://github.com/sacOO7/SocketclusterClientDotNet/blob/95332be2ee06f771229ccc506124fe9677c8bd5f/ScClient/Socket.cs#L120

To work around this I tried to disable to the reconnect strategy so I could write my own. This caused a null reference exception to be thrown after OnDisconnect on my own IBasicListener implementation was called. I believe I have identified the problem on line 120 referenced above. It seems after calling OnDisconnect it calls _strategy.AreAttemptsComplete() without first checking is _strategy is not null.

I have found a workaround for the latter problem, which is to set the max attempts of the reconnect strategy to 0.