-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Conversation
Ping |
src/Components/Browser.JS/src/Platform/Circuits/CircuitHandler.ts
Outdated
Show resolved
Hide resolved
src/Components/test/testassets/ComponentsApp.Server/wwwroot/index.html
Outdated
Show resolved
Hide resolved
src/Components/test/testassets/ComponentsApp.Server/wwwroot/index.html
Outdated
Show resolved
Hide resolved
@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 👍 |
b4443ab
to
2046445
Compare
There was a problem hiding this 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.
src/Components/Browser.JS/src/Platform/Circuits/AutoReconnectCircuitHandler.ts
Outdated
Show resolved
Hide resolved
src/Components/Browser.JS/src/Platform/Circuits/AutoReconnectCircuitHandler.ts
Outdated
Show resolved
Hide resolved
this.intervalHandle = null; | ||
} | ||
onConnectionUp() { | ||
this.modal.style.display = 'none'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
I'm going to limit myself to looking at the C# part of this because steve has that other stuff on lock. |
src/Components/Server/src/Circuits/DisconnectedCircuitRegistry.cs
Outdated
Show resolved
Hide resolved
bbfe6a6
to
07d46b6
Compare
07d46b6
to
82008f2
Compare
🆙 📅 |
/// 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> |
There was a problem hiding this comment.
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++) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Helix failure is https://github.com/aspnet/AspNetCore-Internal/issues/1879 - Unrelated. |
82008f2
to
6da5aa6
Compare
/azp run AspNetCore-helix-test |
Azure Pipelines successfully started running 1 pipeline(s). |
@anurse any idea what failed with the helix run? All I see is
|
For future reference, click any of the #8094 is tracking work to get this data better integrated into AzDO |
Do a reconnect if we have state on the server
Fixes #7537