Skip to content
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

Disable Long Polling Fallback Transport for Blazor Server #470

Closed
2 tasks
TanayParikh opened this issue Jul 26, 2021 · 3 comments
Closed
2 tasks

Disable Long Polling Fallback Transport for Blazor Server #470

TanayParikh opened this issue Jul 26, 2021 · 3 comments
Labels
6.0.0 Announcement Breaking change Documented The breaking change has been published to the .NET Core docs
Milestone

Comments

@TanayParikh
Copy link

TanayParikh commented Jul 26, 2021

Disable Long Polling Fallback Transport for Blazor Server

Long Polling is a fall-back transport utilized when WebSockets aren't available. This can lead to a degraded user experience. Thus, the Long Polling fallback has been removed, and both the client and server now support only WebSockets by default.

Version introduced

.NET 6 rc 1

Old behavior

If WebSockets are unavailable for a circuit (ex. network issues or browser incompatibility), Long Polling is used instead.

New behavior

Client Server Message
WS (without browser WS support) WebSockets Unable to connect, please ensure you are using an updated browser that supports WebSockets.
WS (with WS connection being rejected) WebSockets Unable to connect, please ensure WebSockets are available. A VPN or proxy may be blocking the connection.
WS LongPolling An unhandled error has occurred. Console Error: Unable to initiate a SignalR connection to the server. This might be because the server is not configured to support WebSockets. To troubleshoot this, visit https://aka.ms/blazor-server-websockets-error.
LongPolling WebSockets An unhandled error has occurred.

Reason for change

Improve overall end-user-experience by enforcing WebSocket use.

Recommended action

Ensure WebSockets are functioning as expected with your application. If you must use Long Polling, the following client and server side changes must be made:

Server Side

In Startup.cs, replace endpoints.MapBlazorHub() with:

endpoints.MapBlazorHub(configureOptions: options => 
{ 
    options.Transports = HttpTransportType.WebSockets | HttpTransportType.LongPolling; 
});

Client Side

In Pages/_Layout.cshtml, update the blazor.server.js script tag to include the autostart="false" attribute:

<script src="_framework/blazor.server.js" autostart="false"></script>

Below the blazor.server.js script tag, add the following snippet. WebSockets (1) and Long Polling (4) are the supported HTTPTransportTypes.

<script>
    (function start() {
        Blazor.start({
            configureSignalR: builder => builder.withUrl('_blazor', 1 | 4) // WebSockets and Long Polling
        });
    })()
</script>

Category

  • Binary compatibility (the newer version can be used without recompiling)
  • Source compatibility (successfully recompiling against newer version requires source changes)

Affected APIs

Not detectable via API analysis


Issue metadata

  • Issue type: breaking-change
@TanayParikh TanayParikh added this to the 6.0.0 milestone Jul 26, 2021
@aspnet aspnet locked and limited conversation to collaborators Jul 27, 2021
@gewarren gewarren added the Documented The breaking change has been published to the .NET Core docs label Aug 12, 2021
@mkArtakMSFT
Copy link
Member

Closing as we've reverted this change after discovering some unforeseen effects of it.

@gewarren FYI, in case there was any change made in docs in response to this announcement.

@TanayParikh
Copy link
Author

Closing as we've reverted this change after discovering some unforeseen effects of it.

@gewarren FYI, in case there was any change made in docs in response to this announcement.

Thanks @mkArtakMSFT.

Regarding the documentation, can we leave as is for now (as it reflects the latest RC1 release) and only revert the doc changes when we release RC2. Would like to minimize confusion for those who may still be upgrading to RC1 for the next month or so.

@mkArtakMSFT
Copy link
Member

Yes, of course, @TanayParikh !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
6.0.0 Announcement Breaking change Documented The breaking change has been published to the .NET Core docs
Projects
None yet
Development

No branches or pull requests

3 participants