Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnError, Reconnect not called when Receive throws an exception #23

Open
lheinold opened this issue Sep 13, 2019 · 0 comments
Open

OnError, Reconnect not called when Receive throws an exception #23

lheinold opened this issue Sep 13, 2019 · 0 comments

Comments

@lheinold
Copy link

lheinold commented Sep 13, 2019

I am testing unexpected disconnects and sometimes the following happens:

Exception thrown: 'System.IO.IOException' in System.Net.Sockets.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in System.Net.WebSockets.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in System.Private.CoreLib.dll
2019-09-13T09:41:05.9454580+02:00 PureWebSocket.StartListener: Receive threw an exception: The remote party closed the WebSocket connection without completing the close handshake.
2019-09-13T09:41:05.9471401+02:00 PureWebSocket.StartListener: Listener exiting

Poking through the code I found:

_logger.Log($"Receive threw an exception: {ex.Message}");
// Most likely socket error
 _reconnectNeeded = true;
 _ws.Abort();
break;

I believe that this should invoke OnError and trigger a reconnect (it looks like after listener exits no other tasks are executed, so it doesn't matter if _reconnectNeeded is true). It might also be helpful to rethrow so the client can catch the exception (currently I have no way of telling if this error occurs)

I think this has something to do with the fact that if the monitor loop does not exit properly (like on a break) _isMonitorRunnning continues to be true and the monitor never restarts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant