Bul*_*ets 8 c# nginx websocket blazor
我当前正在运行一个带有 ASP.NET Core 3.1 的网络服务器和一个 Blazor 项目。最近,当升级到 .NET 6.0 时,我遇到了一些问题(即使是空白的 Blazor 项目),仅当部署在我的 Web 服务器上时,浏览器中才会出现 WebSocket 错误消息(请参阅下面的消息)。
本地(在 Windows 11 x64、VS 22 Preview 4 上)没有错误消息...
Web 服务器:Debian 10 x64,安装了 .NET 6.0 SDK,在启用了 Websockets 的 NGINX 上运行(反向代理)。
我是否错过了什么,或者是 .NET 6.0 和 NGINX 当前状态的问题?我已经尝试在 debian 服务器上本地访问该网页,并出现相同的错误消息。
非常感谢您的帮助!
问候!
订单中的错误消息:
Information: Normalizing '_blazor' to 'http://192.168.178.35/_blazor'.
Run Code Online (Sandbox Code Playgroud)
blazor.server.js:1 WebSocket connection to 'ws://192.168.178.35/_blazor?id=wnPt_fXa9H4Jpia530vPWQ' failed:
Run Code Online (Sandbox Code Playgroud)
Information: (WebSockets transport) There was an error with the transport.
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
这是再次描述的解决方案,也许更方便一点:
为了解决这个问题,我在 nginx 的站点配置(/etc/nginx/sites-available)中更改了以下变量:
proxy_set_header Connection $connection_upgrade;
Run Code Online (Sandbox Code Playgroud)
到
proxy_set_header Connection $http_connection;
Run Code Online (Sandbox Code Playgroud)
对我来说这解决了问题。
归档时间: |
|
查看次数: |
7382 次 |
最近记录: |