Skip to content

Disconnect / Reconnect #5282

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

Closed
aswanevelder opened this issue Oct 26, 2017 · 22 comments
Closed

Disconnect / Reconnect #5282

aswanevelder opened this issue Oct 26, 2017 · 22 comments
Assignees
Labels
accepted This issue has completed "acceptance" testing (including accessibility) area-signalr Includes: SignalR clients and servers Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one Needs: Design This issue requires design work before implementating.

Comments

@aswanevelder
Copy link

Hi guys,

Are there javascript events available yet for Disconnect and Reconnect as was available in SignalR 2?

Thanks

@austinfelipe
Copy link

@aswanevelder I don't think so, at least I couldn't find it. I'm doing it using onclose event and just creating a brand new HubConnection 🤔

@moozzyk
Copy link
Contributor

moozzyk commented Oct 26, 2017

There is no reconnect in this version of SignalR so there is no event. onclose is called when the connection is closed.
You can now use websockets to connect to SignalR (i.e. no client is needed) - here is an example (which I need to finish and merge but it should give you an idea)

@davidfowl
Copy link
Member

We're looking at adding the automatic reconnect functionality back to SignalR in the next preview release.

@aswanevelder
Copy link
Author

Thanks guys, @davidfowl looking forward to it!

@KirilRusev
Copy link

@davidfowl sounds great! Do you have road map for the next few months?

@AwsomeCode
Copy link

@davidfowl @aswanevelder @KirilRusev
Please don't add reconnect. Its kind of confusing to manage. If client get disconnected, client can initiate reconnect. Its better that server should not manage reconnects.

@davidfowl
Copy link
Member

It’s all client side. All we’re going to do is make sure the connection is reusable and there’s a way to auto reconnect. The server isn’t managing anything

@analogrelay
Copy link
Contributor

Restarting the connection is now supported in the .NET client (in PR #1147).

#1171 is tracking adding support to the TypeScript client.

Given that, I'm going to close this issue. Feel free to comment if you still have concerns!

@BrennanConroy
Copy link
Member

Reopening, we are going to be adding automatic reconnect

Closed event called once reconnect tries are done
Need to decide on number of reconnect tries
Add configurability
Back-off delay between reconnect tries
StopAsync stops reconnect
Keep connection re-usability

@BrennanConroy BrennanConroy reopened this Jan 26, 2018
@analogrelay analogrelay assigned JamesNK and unassigned BrennanConroy and JamesNK Mar 5, 2018
@analogrelay
Copy link
Contributor

We are going to make the connection restartable (so it's easy to add restart logic), but not automatically restart. We can investigate adding automatic reconnection in a future release.

@Frank802
Copy link

Frank802 commented Apr 6, 2018

Hi guys, I'm developing a local dashboard web app that fetch data from many Rpi connected to the same local network. I'm using HubConnection on client side, with a stream subscribe. It works very well except for the fact that sometimes when I navigate to another page and then return to the dashboard page, I got this error: "cannot send data if the connection is not in the 'connected' state". If I try to refresh the page I got the same error, but if I try to refresh the page using CTRL+F5 (clear cache) It works. I don't understand why, Any Ideas?

Here's my client code:
snip

Thanks :)

@Frank802
Copy link

Frank802 commented Apr 6, 2018

After some tests, I discover that the problem was a 'timing problem'. I was checking the state of my application in order to start the streaming in the windows on load event where the signalR connection sometime was still in connecting state (code=1), that's why sometimes I got that error. I've found this sample that is very helpful to handle this kind of scenario!

@analogrelay analogrelay reopened this Apr 19, 2018
@kmorcinek
Copy link

Disussion is mainly about JavaScript client I guess.
Are you also planning to implement Reconnect in .NET Client? Maybe I should start new issue for that?

@analogrelay
Copy link
Contributor

When we implement automatic reconnect (just to clarify, manual reconnecting is possible today by simply calling StartAsync after the Closed event fires), it will be in both clients.

@radenkozec
Copy link

radenkozec commented Aug 23, 2018

@aswanevelder @davidfowl @kmorcinek Guys can you take a look at my implementation of automatic reconnect for .NET Client and test it to see if it works for you. https://www.radenkozec.com/net-core-signalr-automatic-reconnects/

@analogrelay
Copy link
Contributor

@radenkozec The sample you posted looks good, but you shouldn't have to recreate the HubConnection each time. If you're seeing issues with reusing the same HubConnection instance, let us know in a new issue.

@radenkozec
Copy link

radenkozec commented Aug 23, 2018

@anurse Thanks for feedback. I have improved my code to re-use HubConnection.

@ghost
Copy link

ghost commented Sep 6, 2018

I was about to ask clarifications about how to handle reconnect on the typescript client but I found this in the meantime: dotnet/AspNetCore.Docs#6757

I must say your release process makes me a bit confused but maybe it's just me. Probably it doesn't help (me) that you have .NET and Typescript clients in the same repository. Talking about the Typescript client here, you seem to have some 2.x versions finalised but latest version on npm is 1.0.3, so I don't even know if I will be able to reconnect with 1.03.

@analogrelay
Copy link
Contributor

Since we're now doing this in 3.0. I've split this issue into separate ones for each client (since the work will be done per-client). I'm going to close this issue in lieu of those separate ones now.

@analogrelay analogrelay added enhancement This issue represents an ask for new feature or an enhancement to an existing one Needs: Design This issue requires design work before implementating. and removed enhancement This issue represents an ask for new feature or an enhancement to an existing one type: Enhancement labels Mar 21, 2019
@halter73 halter73 added Done This issue has been fixed and removed 2 - Working labels Apr 8, 2019
@analogrelay analogrelay added the accepted This issue has completed "acceptance" testing (including accessibility) label Apr 16, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted This issue has completed "acceptance" testing (including accessibility) area-signalr Includes: SignalR clients and servers Done This issue has been fixed enhancement This issue represents an ask for new feature or an enhancement to an existing one Needs: Design This issue requires design work before implementating.
Projects
None yet
Development

No branches or pull requests