Configuring Blazor Server to only use WebSockets

See original GitHub issue

I’m trying to configure my Blazor Server app to only use WebSockets as the transport so as to not need to enable sticky sessions on our load balancer. I have tried the following:

_Host.cshtml

	<script src="_framework/blazor.server.js" autostart="false"></script>
	<script>
		Blazor.start({
			configureSignalR: function (builder) {
				builder.withUrl("/_blazor", {
					skipNegotiation: true,
					transport: 1
				});
			}
		});
	</script>

Startup.cs

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

That configuration results in errors:

blazor.server.js:1 WebSocket connection to 'wss://domain.com/_blazor' failed: 
blazor.server.js:1 [2021-04-19T20:04:18.010Z] Error: Failed to start the connection: Error: There was an error with the transport.
blazor.server.js:21 [2021-04-19T20:04:18.011Z] Error: Error: There was an error with the transport.
blazor.server.js:1 Uncaught (in promise) Error: Cannot send data if the connection is not in the 'Connected' State.

Is there a different configuration I need to be doing for Blazor Server to only use WebSockets?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
BrennanConroycommented, Apr 21, 2021

Glad the connection issue was resolved, sending to blazor folks to take a look at the “list of component records is not valid.” error.

0reactions
ryanbueningcommented, Apr 28, 2021

It looks like not having data protection setup was the issue here. Just wanted to follow up for anyone that finds this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Host and deploy Blazor Server - ASP.NET Core
Learn how to host and deploy a Blazor Server app using ASP. ... configure the app to use WebSockets in the Azure portal...
Read more >
WebSockets support in ASP.NET Core
This article explains how to get started with WebSockets in ASP.NET Core. WebSocket (RFC 6455) is a protocol that enables two-way persistent ...
Read more >
.NET 6.0 Blazor Server app: WebSocket connection to 'ws:// ...
go to Turn Windows Features on and off > Internet Information Services > World Wide Web Services > App Development Features > Enable...
Read more >
.NET 6 Blazor Chat with SignalR using WebSockets - YouTube
Blazor E-Commerce Course: https://www.udemy.com/course/ blazor -ecommerce/?couponCode=YOUTUBE Newsletter: ...
Read more >
Let's Learn Blazor: Blazor Server with SignalR
The best choice for most modern browsers is to use WebSockets. You can enabled WebSockets by default in your startup.cs Configure method. app....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found