Skip to content

Don't call close if connect does not succeed #14114

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 4 commits into from
Oct 3, 2019
Merged

Conversation

BrennanConroy
Copy link
Member

@BrennanConroy BrennanConroy commented Sep 18, 2019

Fixes #14075

Description

There is a race when falling back from WebSockets to other transports that will prevent fallback from working. This code was refactored in 3.0 which caused this regression. When a WebSocket connection failed to start, the WebSocket transport code would signal both that the connection failed to start and that the connection was closed. This would cause a race in the SignalR logic and if the wrong path wins the race, the connection is closed entirely instead of falling back to other transports.

Customer Impact

In situations where an intermediary (i.e. not the client, and not the app server) doesn't support WebSockets, the client may fail to connect where previously it would have fallen back to a different transport. Generally this wouldn't have a huge impact except that by default Azure App Service has an intermediary that doesn't support WebSockets. It can be enabled by users, but many customers don't enable it or don't wish to enable it. It is also a regression of a core functionality of SignalR (fallback) in 3.0.

Regression?

Yes, regression in 3.0 from the 2.2 behavior

Risk

Low, added test coverage to prevent this kind of issue in the future

@BrennanConroy BrennanConroy added the area-signalr Includes: SignalR clients and servers label Sep 18, 2019
@BrennanConroy BrennanConroy added this to the 3.0.x milestone Sep 18, 2019

expect(connectComplete).toBe(false);

TestWebSocket.webSocket.onclose(new TestEvent());
Copy link
Member

Choose a reason for hiding this comment

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

Nit: might be nice to test this with an ErrorEvent.

@halter73
Copy link
Member

Why the [Do Not Merge]?

@BrennanConroy
Copy link
Member Author

Why the [Do Not Merge]?

To not scare Doug 😛

Also, because 3.0 isn't ready for patch work.

@analogrelay
Copy link
Contributor

@BrennanConroy put the servicing goop in (Customer Impact, a brief description, risk, etc.)

@analogrelay analogrelay added Servicing-consider Shiproom approval is required for the issue and removed Servicing-consider Shiproom approval is required for the issue labels Sep 18, 2019
@BrennanConroy
Copy link
Member Author

put the servicing goop in (Customer Impact, a brief description, risk, etc.)

@anurse Done, if you'd like to wordsmith it a bit (since you're better at that than I am) go for it.

@BrennanConroy BrennanConroy changed the title [Do Not Merge] Don't call close if connect does not succeed Don't call close if connect does not succeed Sep 23, 2019
@BrennanConroy BrennanConroy marked this pull request as ready for review September 23, 2019 20:36
@BrennanConroy BrennanConroy requested review from mikaelm12 and a team as code owners September 23, 2019 20:36
@BrennanConroy BrennanConroy added the Servicing-consider Shiproom approval is required for the issue label Sep 23, 2019
@@ -70,4 +70,9 @@ Later on, this will be checked using this condition:
Microsoft.AspNetCore.SpaServices;
</PackagesInPatch>
</PropertyGroup>
<PropertyGroup Condition=" '$(VersionPrefix)' == '3.0.1' ">
Copy link
Contributor

Choose a reason for hiding this comment

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

🥇

@analogrelay analogrelay added the ask-mode This issue / PR is a patch candidate which we will bar-check internally before patching it. label Sep 24, 2019
@analogrelay
Copy link
Contributor

analogrelay commented Sep 24, 2019

Approved by Tactics for 3.0 servicing. Please ⚠️ do not merge ⚠️ for right now though. I think we need to do branding updates before merging servicing fixes (cc @aspnet/build @Pilchie)

@dougbu
Copy link
Contributor

dougbu commented Sep 24, 2019

Yeah, I'm working on those branding updates -- an expansion of aspnet/AspNetCore-Internal#3153 that I started on last night

@analogrelay analogrelay removed ask-mode This issue / PR is a patch candidate which we will bar-check internally before patching it. Servicing-consider Shiproom approval is required for the issue labels Sep 26, 2019
@analogrelay
Copy link
Contributor

Branches are ✔ Open ✔ for 3.0.1 changes. Since this is approved and has the patch config goop. This can be merged when ready (and builds are green).

@analogrelay analogrelay modified the milestones: 3.0.x, 3.0.1 Oct 1, 2019
@BrennanConroy
Copy link
Member Author

Note: People who can merge, don't do so without talking to me first please. Need to verify the runtime is updated etc.

@BrennanConroy
Copy link
Member Author

@aspnet-hello
Copy link

@BrennanConroy BrennanConroy added the Servicing-approved Shiproom has approved the issue label Oct 2, 2019
@dougbu dougbu merged commit ac261d8 into release/3.0 Oct 3, 2019
@dougbu dougbu deleted the brecon/fallback branch October 3, 2019 15:27
@DNF-SaS
Copy link

DNF-SaS commented Oct 16, 2019

Guys, whatsup with this issue - it's really hitting us hard because we have firewalls without WebSocket-Support!

@BrennanConroy
Copy link
Member Author

If you know that WebSockets are not supported you can set the supported transports on your hub endpoint so clients don't even try to use WebSockets

See the Transports option in https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-3.0&tabs=dotnet#advanced-http-configuration-options

@analogrelay
Copy link
Contributor

analogrelay commented Oct 17, 2019

@DNF-SaS It'll be fixed in the upcoming 3.0.1 patch. The date is TBD as there are some blocking issues we are working to resolve but we are working on getting out as quickly as possible. It'll also be fixed in the 3.1 release scheduled by the end of the year. I know this is a bad one, we're working on getting a fix out ASAP.

My recommendation for now would be to hold the update to 3.0 if you're affected by this. Watch the .NET Blog for a post when the 3.0.1 patch is available.

@paralaxsd
Copy link

If you know that WebSockets are not supported you can set the supported transports on your hub endpoint so clients don't even try to use WebSockets

See the Transports option in https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-3.0&tabs=dotnet#advanced-http-configuration-options

It wasn't immediately clear to me where to set this up exactly. Should anyone else struggle in the time until 3.0.1, this worked for me as temp workaround in Startup.Configure:

app.UseEndpoints(endpoints =>
{
    endpoints.MapBlazorHub(options =>
    {
        options.Transports = HttpTransportType.LongPolling;
    });
    endpoints.MapFallbackToPage("/_Host");
});

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.

7 participants