skip to Main Content

I am running currently a webserver with ASP.NET Core 3.1 and a Blazor project.
Recently when upgrading to .NET 6.0 I encountered (even with a blank Blazor project) some problems with a websocket error message in the browser only when deployed on my webserver (see message below).

Locally (on Windows 11 x64, VS 22 Preview 4) there are no error messages…

Webserver: Debian 10 x64, .NET 6.0 SDK installed, running on NGINX with websockets enabled (reverse proxy).

Do I miss out on something or is it a problem with the current state of .NET 6.0 and NGINX? I already tried to access the webpage locally on the debian server and the same error message occurs.

Help would be much appreciated!

Greetings!

Error messages within order:

Information: Normalizing '_blazor' to 'http://192.168.178.35/_blazor'.

blazor.server.js:1 WebSocket connection to 'ws://192.168.178.35/_blazor?id=wnPt_fXa9H4Jpia530vPWQ' failed:

Information: (WebSockets transport) There was an error with the transport.

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.

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.

2

Answers


  1. Chosen as BEST ANSWER

    Here is the solution described again, maybe a little bit more convenient:

    To fix this problem, I changed in the site-configuration (/etc/nginx/sites-available) of nginx the following variables:

    proxy_set_header Connection $connection_upgrade;
    

    to

    proxy_set_header Connection $http_connection;
    

    For me this solved the problem.


  2. Based on Bullets response and https://nginx.org/en/docs/http/websocket.html

    Edit your site configuration on /etc/nginx/sites-available

    Replace:

    proxy_set_header Connection keep-alive;
    

    With:

    proxy_set_header Connection "upgrade";
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search