Actualmente estoy ejecutando un servidor web con ASP.NET Core 3.1 y un proyecto Blazor. Recientemente, al actualizar a .NET 6.0, encontré (incluso con un proyecto Blazor en blanco) algunos problemas con un mensaje de error de websocket en el navegador solo cuando se implementó en mi servidor web (consulte el mensaje a continuación).
Localmente (en Windows 11 x64, VS 22 Preview 4) no hay mensajes de error...
Servidor web: Debian 10 x64, .NET 6.0 SDK instalado, ejecutándose en NGINX con websockets habilitados (proxy inverso).
¿Me pierdo algo o es un problema con el estado actual de .NET 6.0 y NGINX? Ya intenté acceder a la página web localmente en el servidor debian y aparece el mismo mensaje de error.
¡La ayuda sería muy apreciada!
¡Saludos!
Mensajes de error dentro del pedido:
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.Aquí está la solución descrita nuevamente, tal vez un poco más conveniente:
Para solucionar este problema, cambié en la configuración del sitio (/etc/nginx/sites-disponible) de nginx las siguientes variables:
proxy_set_header Connection $connection_upgrade;para
proxy_set_header Connection $http_connection;Para mí esto resolvió el problema.