Skip to content

Client reconnects when state's available on the server #7395

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 11 commits into from
Mar 5, 2019

Conversation

pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Feb 8, 2019

Do a reconnect if we have state on the server

Fixes #7537

@pranavkm pranavkm requested a review from rynowak February 8, 2019 19:21
@Eilon Eilon added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Feb 10, 2019
@pranavkm
Copy link
Contributor Author

Ping

@SteveSandersonMS
Copy link
Member

@pranavkm Hope you don't mind the big pile of comments on the TypeScript! Besides that stylistic stuff, this really looks like it's heading in the right direction 👍

Copy link
Contributor Author

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

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

🆙 📅 There's a minimal UI that attempts to do an auto-reconnect.

this.intervalHandle = null;
}
onConnectionUp() {
this.modal.style.display = 'none';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Testing this is going to be tricky. With a local host, reconnect simulated using a forced disconnect is almost instant. I could try adding another handler that does busy waiting until the test has an opportunity to inspect things. Any suggestions on a better plan to test the UI?

Copy link
Member

Choose a reason for hiding this comment

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

Since we have an internal-for-testing method _internal.forceCloseConnection, we could go further with that pattern and change it to a pair of methods like _internal.goOffline (disconnects, and sets a flag that makes reconnect into a no-op), and _internal.goOnline (clears the flag so that reconnect now does its normal thing).

Copy link
Member

Choose a reason for hiding this comment

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

Unresolving just so you see this. Totally understand if you don't feel there's time to change this further before preview 3!

Copy link
Member

Choose a reason for hiding this comment

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

Another possibility I've looked into, but don't have a definitive answer about, is whether Selenium can make the browser switch into "offline" mode then back "online" later. That would be ideal, but people on the internets seem disagreed about whether this is supported and what the code to do it would be.

Copy link
Member

Choose a reason for hiding this comment

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

Would something like this work?

  • Extend ComponentHub and add an additional InterruptConnection method.
  • Have that method close the connection (as it's the same client proxy).
  • Register that on the functional tests.
  • Call that from your code to trigger it.

@rynowak
Copy link
Member

rynowak commented Feb 15, 2019

I'm going to limit myself to looking at the C# part of this because steve has that other stuff on lock.

@pranavkm pranavkm force-pushed the prkrishn/reconnect branch 2 times, most recently from bbfe6a6 to 07d46b6 Compare February 27, 2019 19:31
@pranavkm
Copy link
Contributor Author

🆙 📅

/// While <see cref="OnConnectionUpAsync(Circuit, CancellationToken)"/> is always invoked when a client
/// connects to the server, <see cref="OnConnectionDownAsync(Circuit, CancellationToken)"/> may not be invoked
/// if a client reconnects prior to the server identifying a client disconnect.
/// </remarks>
Copy link
Member

Choose a reason for hiding this comment

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

@pranavkm - per offline discussion revert this


private async Task OnCircuitDownAsync()
{
for (var i = 0; i < _circuitHandlers.Length; i++)
Copy link
Member

Choose a reason for hiding this comment

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

this isn't protected by the lock.. is this an issue? or is this protected by the design of the circuit pool?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Neither of the circuit events have concurrency issues - the server controls when a circuit is being discarded so it doesn't need protection.

if (circuitHost == null)
{
// Failed to connect. Nothing to do here.
return null;
Copy link
Member

Choose a reason for hiding this comment

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

null task :( that's pretty unconventional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's async method, so it's a null value (not null Task).

{
// During reconnects, we may transition from Connect->Connect i.e.without ever having invoking OnConnectionDownAsync during
// a formal client disconnect. To allow authors of CircuitHandlers to have reasonable expectations will pair the connection up with a connection down.
await circuitHost.OnConnectionDownAsync(cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

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

👍

@analogrelay
Copy link
Contributor

Helix failure is https://github.com/aspnet/AspNetCore-Internal/issues/1879 - Unrelated.
AspNetCore-ci failure is an out of date ref-asm file since a public API was added.

@pranavkm pranavkm force-pushed the prkrishn/reconnect branch from 82008f2 to 6da5aa6 Compare March 4, 2019 22:22
@analogrelay
Copy link
Contributor

/azp run AspNetCore-helix-test

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pranavkm
Copy link
Contributor Author

pranavkm commented Mar 5, 2019

@anurse any idea what failed with the helix run? All I see is

E:\A\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19105.2\tools\Microsoft.DotNet.Helix.Sdk.MultiQueue.targets(71,5): error : Job '44eeb84b-c926-4086-9905-d39616de4913' has 1 failed work items. [E:\A\_work\1\s\eng\helix\helix.proj]
E:\A\_work\1\s\.nuget\packages\microsoft.dotnet.helix.sdk\2.0.0-beta.19105.2\tools\Microsoft.DotNet.Helix.Sdk.MultiQueue.targets(71,5): error : Job '1861a084-5a19-46c4-af02-0fabc5334641' has 1 failed work items. [E:\A\_work\1\s\eng\helix\helix.proj]

@pranavkm pranavkm merged commit 33839dc into master Mar 5, 2019
@pranavkm pranavkm deleted the prkrishn/reconnect branch March 5, 2019 01:27
@analogrelay
Copy link
Contributor

For future reference, click any of the mc.dot.net links above those messages (they're all the same) when they occur to get to a screen that lets you drill down into failures.

image

#8094 is tracking work to get this data better integrated into AzDO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants