Skip to content

Blazor Server .net 9 Websocket connection fails, Same site with .net 8 works fine #58932

Closed
@selaromdotnet

Description

@selaromdotnet

I'm encountering a strange issue and I'm not really sure how to approach it. I host my websites with smarterasp.net which added support for .net 9 with yesterday's release...

However, after upgrading and publishing my blazor server app from .net 8.0 to 9.0, it is failing to establish the websocket connection and not running as expected.

The only difference between these two sites is the .net version (and the associated nuget packages), so I can only think that it's a problem with the environment or a bug, and I'm not really sure how to confirm either...

I published the .net 8 site here: https://dev.mcallengaragesales.com which loads and connects and seems to run fine on Firefox, edge, chrome on both desktop and mobile.

I upgraded that same site to .net 9 and published it here: https://dev9.mcallengaragesales.com and on firefox desktop I get this error:

[2024-11-13T22:05:24.792Z] Information: Normalizing '_blazor' to 'https://dev9.mcallengaragesales.com/_blazor'. [blazor.web.js:1:47102](https://dev9.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:05:25.504Z] Information: WebSocket connected to wss://dev9.mcallengaragesales.com/_blazor?id=VYh6X3Cn47ojOab5M2uiXQ. [blazor.web.js:1:47102](https://dev9.mcallengaragesales.com/_framework/blazor.web.js)
The connection to wss://dev9.mcallengaragesales.com/_blazor?id=VYh6X3Cn47ojOab5M2uiXQ was interrupted while the page was loading. [blazor.web.js:1:80199](https://dev9.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:05:44.757Z] Information: (WebSockets transport) There was an error with the transport. [blazor.web.js:1:47102](https://dev9.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:05:44.758Z] Error: Connection disconnected with error 'Error: WebSocket closed with status code: 1006 (no reason given).'. [blazor.web.js:1:47019](https://dev9.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:05:44.758Z] Error: Error: WebSocket closed with status code: 1006 (no reason given). [blazor.web.js:1:39473](https://dev9.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:05:44.758Z] Error: Error: Cannot send data if the connection is not in the 'Connected' State. [blazor.web.js:1:39473](https://dev9.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:05:44.758Z] Information: Normalizing '_blazor' to 'https://dev9.mcallengaragesales.com/_blazor'. [blazor.web.js:1:47102](https://dev9.mcallengaragesales.com/_framework/blazor.web.js)
Firefox can’t establish a connection to the server at wss://dev9.mcallengaragesales.com/_blazor?id=182Go0fRvtQfWVWgU8PcYw. [blazor.web.js:1:80199](https://dev9.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:05:45.486Z] Information: (WebSockets transport) There was an error with the transport. [blazor.web.js:1:47102](https://dev9.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:05:45.486Z] Error: Failed to start the transport 'WebSockets': Error: WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.

On chrome desktop I get a similar but slightly different error:

[2024-11-13T22:04:43.733Z] Information: Normalizing '_blazor' to 'https://dev9.mcallengaragesales.com/_blazor'.
blazor.web.js:1 WebSocket connection to 'wss://dev9.mcallengaragesales.com/_blazor?id=nXyCEXfix-zJi1n89EgOrg' failed: 
(anonymous) @ blazor.web.js:1Understand this errorAI
blazor.web.js:1 [2024-11-13T22:04:44.158Z] Information: (WebSockets transport) There was an error with the transport.
blazor.web.js:1 [2024-11-13T22:04:44.158Z] Error: Failed to start the transport 'WebSockets': Error: WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.
log @ blazor.web.js:1Understand this errorAI
blazor.web.js:1 [2024-11-13T22:04:44.503Z] Warning: Failed to connect via WebSockets, using the Long Polling fallback transport. This may be due to a VPN or proxy blocking the connection. To troubleshoot this, visit https://aka.ms/blazor-server-using-fallback-long-polling.

On mobile, the .net 9 site simply shows the standard blazor error with reload message at the footer (I don't know how to see dev tools on android to get more detailed errors)...

As an attempt to eliminate any other variables, I created a brand new, clean, default blazor web site for .net 9 using server interactive in visual studio and published that here: http://test.mcallengaragesales.com

and in firefox on THAT site, I get this error:

[2024-11-13T22:09:59.631Z] Information: Normalizing '_blazor' to 'http://test.mcallengaragesales.com/_blazor'. [blazor.web.js:1:47102](http://test.mcallengaragesales.com/_framework/blazor.web.js)
Firefox can’t establish a connection to the server at ws://test.mcallengaragesales.com/_blazor?id=e_FiqjqOx95vihFDg7P8CA. [blazor.web.js:1:80199](http://test.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:09:59.984Z] Information: (WebSockets transport) There was an error with the transport. [blazor.web.js:1:47102](http://test.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:09:59.985Z] Error: Failed to start the transport 'WebSockets': Error: WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled. [blazor.web.js:1:47019](http://test.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:10:00.708Z] Warning: Failed to connect via WebSockets, using the Long Polling fallback transport. This may be due to a VPN or proxy blocking the connection. To troubleshoot this, visit https://aka.ms/blazor-server-using-fallback-long-polling. [blazor.web.js:1:39512](http://test.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:10:01.576Z] Error: There was an error applying batch 2. [blazor.web.js:1:39473](http://test.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:10:01.579Z] Error: There was an error applying batch 3. [blazor.web.js:1:39473](http://test.mcallengaragesales.com/_framework/blazor.web.js)
[2024-11-13T22:10:01.805Z] Error: System.AggregateException: One or more errors occurred. (TypeError: n.parentNode is null)

 ---> System.InvalidOperationException: TypeError: n.parentNode is null

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InvokeRenderCompletedCallsAfterUpdateDisplayTask(Task updateDisplayTask, Int32[] updatedComponents)

   --- End of inner exception stack trace --- [blazor.web.js:1:39473](http://test.mcallengaragesales.com/_framework/blazor.web.js)
XHRPOST
http://test.mcallengaragesales.com/_blazor?id=_pNXLGiS-NE3aR74tAFcdQ
[HTTP/1.1 404 Not Found 88ms]

[2024-11-13T22:10:01.948Z] Information: Connection disconnected. [blazor.web.js:1:47102](http://test.mcallengaragesales.com/_framework/blazor.web.js)

and this on edge:

[2024-11-13T22:11:15.038Z] Information: Normalizing '_blazor' to 'http://test.mcallengaragesales.com/_blazor'.
blazor.web.js:1 [2024-11-13T22:11:15.282Z] Information: WebSocket connected to ws://test.mcallengaragesales.com/_blazor?id=WlqbMNRCNy-5sQk5zMEA2A.
blazor.web.js:1  [2024-11-13T22:11:15.283Z] Error: Connection disconnected with error 'Error: WebSocket closed with status code: 1006 (no reason given).'.
log @ blazor.web.js:1
_stopConnection @ blazor.web.js:1
features.reconnect.transport.onclose @ blazor.web.js:1
_close @ blazor.web.js:1
i.onclose @ blazor.web.js:1
blazor.web.js:1  [2024-11-13T22:11:15.283Z] Error: Error: WebSocket closed with status code: 1006 (no reason given).
log @ blazor.web.js:1
unhandledError @ blazor.web.js:1
startConnection @ blazor.web.js:1
await in startConnection
startCore @ blazor.web.js:1
start @ blazor.web.js:1
Qo @ blazor.web.js:1
await in Qo
Yo @ blazor.web.js:1
startCircutIfNotStarted @ blazor.web.js:1
resolveRendererIdForDescriptor @ blazor.web.js:1
determinePendingOperation @ blazor.web.js:1
refreshRootComponents @ blazor.web.js:1
(anonymous) @ blazor.web.js:1
setTimeout
rootComponentsMayRequireRefresh @ blazor.web.js:1
onDocumentUpdated @ blazor.web.js:1
Hi @ blazor.web.js:1
blazor.web.js:1  [2024-11-13T22:11:15.284Z] Error: Failed to start the circuit.


I am at a total loss for what to do. I want to publish the .net 9 site live today but I can't with this issue. I'm hoping it's an environment thing as opposed to a bug in my code (or .net) but at the same time I have no idea what to tell my host to try and remedy the issue...

Does anyone else get any different result than I am showing above? Any ideas what might be wrong here? anything more I can provide to give more insight?

many thanks for taking a look!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions