Configuring Blazor Server to only use WebSockets
See original GitHub issueI’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:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Glad the connection issue was resolved, sending to blazor folks to take a look at the “list of component records is not valid.” error.
It looks like not having data protection setup was the issue here. Just wanted to follow up for anyone that finds this.