Skip to content

Graceful reconnection alternative #12853

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

Merged
merged 5 commits into from
Aug 7, 2019

Conversation

javiercn
Copy link
Member

@javiercn javiercn commented Aug 3, 2019

  • Uses the send beacon API instead of relying on SignalR disconnect feature
  • Works as we expect in the three cases we care about:
    • User refreshes the window.
    • User closes the browser.
    • User navigates away from the page.
  • It introduces an additional POST endpoint at path+/disconnect that receives the circuit id in a form post value and processes it.
    • We don't need to worry about CSRF here because the circuit ID is not guessable.
    • If we want to be extra careful we could also require the circuit being disconnected from the hub before we fully terminate it. (Meaning the beacon would simply add a flag to the circuit and Registry.DisconnectAsync would check this flag to take down the circuit completely or we would take down the circuit completely if it was already disconnected when we received the flag).
  • None of these things are in reality a problem as DisconnectAsync already has logic to handle these and the beacon gets sent when the page unloads, so there is little/no chance of receiving any interop/event call at that point.

image

@rynowak
Copy link
Member

rynowak commented Aug 3, 2019

@GrabYourPitchforks FYI

I want to make sure we get a signoff re: security for something we're adding this late in the game.

I'm impressed on the quick turnaround on this 😆

Copy link
Member

@rynowak rynowak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor feedback, this looks really good so far.

@rynowak
Copy link
Member

rynowak commented Aug 3, 2019

Tests? Both for the new endpoint and for the disconnection functionality in general? We might need to add a "test" endpoint to the server that can be used to query circuits.

Copy link
Member

@SteveSandersonMS SteveSandersonMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this! Seems so much clearer than trying to guess based on heartbeats.

I'm approving now because this looks so good, but I'm sure you'll address the comments too.

@SteveSandersonMS
Copy link
Member

SteveSandersonMS commented Aug 5, 2019

Based on @anurse's comments elsewhere, maybe at some point in the future SignalR could introduce a new method for notifying the app about definitely-graceful disconnections, if it turns out we can reliably distinguish between things like "user switched phone into flight mode" (ungraceful) and "user navigated away from page" (graceful).

If that does become true in the future, maybe that would be even more reliable than using beacons, since it would be harder for a misbehaving client to mislead us. We'd be free to switch to a different implementation, since this beacon technique is purely an internal implementation detail. For now, the beacon definitely looks like the best bet to me.

@Eilon Eilon added the area-blazor Includes: Blazor, Razor Components label Aug 5, 2019
@javiercn javiercn force-pushed the javiercn/graceful-disconnection-alternative branch from 97a21fd to 102efca Compare August 5, 2019 21:17
@javiercn
Copy link
Member Author

javiercn commented Aug 5, 2019

🆙 📅 Will merge tomorrow unless there's important feedback

@javiercn javiercn force-pushed the javiercn/graceful-disconnection-alternative branch from 102efca to 18d145b Compare August 7, 2019 13:33
@javiercn javiercn merged commit 25c240b into release/3.0 Aug 7, 2019
@ghost ghost deleted the javiercn/graceful-disconnection-alternative branch August 7, 2019 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants