Skip to content

[SignalR] Pass new App to Transport Pipe to App layer #49650

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 8 commits into from
Aug 22, 2023

Conversation

BrennanConroy
Copy link
Member

@BrennanConroy BrennanConroy commented Jul 26, 2023

Pass new 'App to Transport Pipe' to 'App layer'

Removes the use of ConnectionResetException to let the app layer know the connection is being replaced. Instead we pass the new Pipe to the App layer so it knows when a new underlying connection is present.

Also, adds DisableReconnect so the app layer can let the connection layer know that new connections shouldn't be allowed anymore.

@BrennanConroy BrennanConroy added the area-signalr Includes: SignalR clients and servers label Jul 26, 2023
@BrennanConroy BrennanConroy requested a review from halter73 July 26, 2023 16:05
@BrennanConroy BrennanConroy marked this pull request as ready for review August 9, 2023 17:57
@@ -579,6 +579,13 @@ private async Task StopAsyncCore(bool disposing)
TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted,
TaskScheduler.Default);
}

#pragma warning disable CA2252 // This API requires opting into preview features
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean that if we do make API changes to preview features in 9.0, it could make things break harder when mixing 8.0 and 9.0 packages?

Copy link
Member Author

Choose a reason for hiding this comment

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

So like the following examples:

  • If you used 8.0 client on the server that targets 9.0
  • If you use Connection.Abstractions 9.0 with 8.0 client

Yeah that does seem bad :/
Generally we say "use the same version packages" since we ship everything at the same time. But it's sort of a cop-out.

public void DisableReconnect()
#pragma warning restore CA2252 // This API requires opting into preview features
{
_useAck = false;
Copy link
Member

@halter73 halter73 Aug 16, 2023

Choose a reason for hiding this comment

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

Doesn't it feel like this should be synchronized? Same with the variant in HttpConnectionContext. What if we fire the notifyOnReconnect event way after DisableReconnect() returns? Potentially after the transport and/or connection have fully closed? Could the client start reconnecting after it has already sent a close message over the previous WebSocket due to StopAsync()?

try
{
var reconnectTask = connection.NotifyOnReconnect?.Invoke(connection.Transport.Output) ?? Task.CompletedTask;
await reconnectTask;
Copy link
Member

@halter73 halter73 Aug 16, 2023

Choose a reason for hiding this comment

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

Do we really want to await resending everything before disabling the request body timeout? It seems like that could cause us to close healthy connections. Is there any possible benefit to awaiting this task immediately rather than putting it in the WhenAny?

The same goes on the client side even though there's no IHttpRequestTimeoutFeature. Why would the implementor of NotifyOnReconnect ever want to delay execution of anything at the Http.Connections layer? What's the reconnectTask for? I assumed it was just better error reporting. @davidfowl

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there any possible benefit to awaiting this task immediately rather than putting it in the WhenAny?

Well the WhenAny is for when the connection is closing, either due to the transport detecting a disconnect or the application completing. So we'd still want to wait for the reconnect task separately. But we should put that after the IHttpRequestTimeoutFeature.

/// <summary>
/// Called when a connection reconnects. The new <see cref="PipeWriter"/> that application code should write to is passed in.
/// </summary>
public void OnReconnected(Func<PipeWriter, Task> notifyOnReconnect);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public void OnReconnected(Func<PipeWriter, Task> notifyOnReconnect);
public void OnReconnected(Func<PipeWriter, Task> callback);

@BrennanConroy BrennanConroy changed the base branch from main to release/8.0-rc1 August 17, 2023 21:29
@BrennanConroy BrennanConroy added the Servicing-consider Shiproom approval is required for the issue label Aug 17, 2023
@ghost
Copy link

ghost commented Aug 17, 2023

Hi @BrennanConroy. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge.

To learn more about how to prepare a servicing PR click here.

@BrennanConroy BrennanConroy added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Aug 21, 2023
@ghost
Copy link

ghost commented Aug 21, 2023

Hi @BrennanConroy. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed.

@adityamandaleeka adityamandaleeka enabled auto-merge (squash) August 22, 2023 00:03
@adityamandaleeka
Copy link
Member

This came in before 5 and will get merged, but I'm waiting for a build to succeed after the latest merge conflict resolution.

@adityamandaleeka adityamandaleeka merged commit e3eb451 into release/8.0-rc1 Aug 22, 2023
@adityamandaleeka adityamandaleeka deleted the brecon/noex branch August 22, 2023 01:49
@ghost ghost added this to the 8.0-rc1 milestone Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants