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

OnOpened Event didn't fire after reconnect #15

Open
thetpaingwynn opened this issue May 8, 2019 · 2 comments
Open

OnOpened Event didn't fire after reconnect #15

thetpaingwynn opened this issue May 8, 2019 · 2 comments
Assignees

Comments

@thetpaingwynn
Copy link

I'm not getting OnOpened Event after websocket close and reconnected. But websocket was reconnected successfully. Here is the error.

System.OperationCanceledException: The operation was canceled.
   at System.Collections.Concurrent.BlockingCollection`1.TryTakeWithNoTimeValidation(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken, CancellationTokenSource combinedTokenSource)
   at System.Collections.Concurrent.BlockingCollection`1.TryTake(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Collections.Concurrent.BlockingCollection`1.Take(CancellationToken cancellationToken)
   at PureWebSockets.PureWebSocket.<StartSender>b__59_0()
@ByronAP
Copy link
Contributor

ByronAP commented May 14, 2019

This is by design (reconnecting without firing an event). We could make this an optional behavior. Could you give a bit more information about the error and how it relates to auto reconnect?

@thetpaingwynn
Copy link
Author

Hi @ByronAP,
Sorry for late reply. If it is by design then let it be. But It will be nice if we have option to fire event upon successful re-connection. Because some websocket require to send subscribe message upon reconnect.

Here is the information about the error and my setup.

I initialize the websocket with ReconnectStrategy like this

_webSocket = new PureWebSocket(_url, new PureWebSocketOptions
{
    DebugMode = true,
    SendDelay = 100,
    IgnoreCertErrors = true,
    MyReconnectStrategy = new ReconnectStrategy(1000)
});

At some point OnError event fired with this exception

System.OperationCanceledException: The operation was canceled.
   at System.Collections.Concurrent.BlockingCollection`1.TryTakeWithNoTimeValidation(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken, CancellationTokenSource combinedTokenSource)
   at System.Collections.Concurrent.BlockingCollection`1.TryTake(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Collections.Concurrent.BlockingCollection`1.Take(CancellationToken cancellationToken)
   at PureWebSockets.PureWebSocket.<StartSender>b__59_0()

OnStateChanged event fired with State: Aborted,
then OnStateChanged event fired again with State: Connecting
After that I got welcome message from Websocket which is send upon every successful connection.

@ByronAP ByronAP self-assigned this Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants