pusher / pusher-websocket-dotnet

Pusher Channels Client Library for .NET
MIT License
112 stars 113 forks source link

Unable to recover from a lost connection #70

Closed cdauphinee closed 4 years ago

cdauphinee commented 5 years ago

If I disconnect my machine from the network after connecting to Pusher, I receive three ConnectionStateChanged events:

When I reconnect to the network, the client doesn't automatically reconnect. If I try to call ConnectAsync to manually reconnect, it returns AlreadyConnected, even though the connection state is Initialized. If I try calling DisconnectAsync before reconnecting, I receive the same result.

From the code, it looks like ConnectAsync can only be called once per instance. I can work around this by recreating my Pusher instance when I lose my connection, but this isn't ideal.

ShireOakDan commented 4 years ago

Is there any update on this at all as I am finding the same issue.

Connect used to work fine but now it's been replaced with an Async it doesn't reconnect after network loss which I agree isn't ideal.

imaji commented 4 years ago

I'm doing some work in there now. Do you have steps to reproduce? Ideally a test of some kind?

ShireOakDan commented 4 years ago

I can try and post some actual code later as I am away from computer at the moment but as a simple test to reproduce.

The issue can be achieved using some of the Usage example.

Connect to pusher and write connection state changes to the console. Disconnect from your network temporarily and then reconnect to the network and the pusher instance won't reconnect.

Sorry if this isn't clear I'm writing on my mobile!

imaji commented 4 years ago

Not at all.

Found it & fixed. The branch I'm working on should be going live shortly.

ShireOakDan commented 4 years ago

Just noticed a fix has been pushed for this, excellent work thank you.

When will this get applied to the NuGet package?

imaji commented 4 years ago

Yup, going to do some further testing, then it should end up in Nuget shortly :)

ShireOakDan commented 4 years ago

Great! Thanks again

MPNGZ commented 4 years ago

Hi sorry for jumping on this thread - just found this after doing a little bit of googling of the issue.

I use Nuget and notice you have mentioned you will be updating the package, do you have an ETA on when it will be available as an update please? :)

ShireOakDan commented 4 years ago

Just had an alert to say to 1.1.0 was released. Updated package and for some reason the connection doesn't recover.

Steps: Started my application which automatically connects and subscribes, I sent a test event which came through, I then disconnected my WiFi for 30 seconds, and turned it back on and it didn't reconnect.

Not sure if this helps but it's from my connection log:

11/10/2019 14:35:18 - Initialized 11/10/2019 14:35:20 - Subscribed 11/10/2019 14:35:30 - { "event": "App\Events\ItemUpdated", "data": "{\"item\":\"test\"}", "channel": "private-items.test" } 11/10/2019 14:35:41 - Disconnected 11/10/2019 14:35:41 - WaitingToReconnect 11/10/2019 14:35:41 - Initialized 11/10/2019 14:35:41 - Disconnected 11/10/2019 14:35:41 - WaitingToReconnect