部署的.NET Core 6 Blazor Server应用清缓存后停止处理HTTP请求
异常问题求助:Blazor Server跨区域客户端异常
问题现象
- 奥地利的iOS用户清理浏览器缓存并重连网站后,应用虽能正常打开,但不再处理任何HTTP请求(如URL加载的logo及其他资源请求)
- 该异常会影响所有其他客户端,并非仅出现问题的用户
- 部署环境:西欧区域的Azure App Service,Linux和Windows计划均存在此问题
- 基于SignalR构建,但日志(已开启DEBUG级别)未记录WebSocket断开错误,也无可用的错误追踪信息
- 尝试调整多种Hub连接配置(当前配置如下),问题仍未解决;本地环境无法复现该异常,页面加载正常无崩溃迹象
服务端配置
services.AddServerSideBlazor() .AddHubOptions(options => { options.HandshakeTimeout = TimeSpan.FromSeconds(15); options.KeepAliveInterval = TimeSpan.FromSeconds(15); options.ClientTimeoutInterval = TimeSpan.FromSeconds(40); options.EnableDetailedErrors= true; }) .AddCircuitOptions(options => { options.DetailedErrors = true; });
客户端配置
public static HubConnection TryInitialize(this HubConnection hubConnection, NavigationManager navigationManager) { if (hubConnection == null) { hubConnection = new HubConnectionBuilder() .WithUrl(navigationManager.ToAbsoluteUri(ApplicationConstants.SignalR.HubUrl)) .Build(); hubConnection.HandshakeTimeout = TimeSpan.FromSeconds(15); hubConnection.KeepAliveInterval = TimeSpan.FromSeconds(15); hubConnection.ServerTimeout = TimeSpan.FromSeconds(40); } return hubConnection; }
日志配置
"Logging": { "LogLevel": { "Default": "Debug", "Microsoft": "Debug", "Hangfire": "Debug", "Microsoft.Hosting.Lifetime": "Debug", "Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware": "Debug", "Microsoft.AspNetCore.SignalR": "Debug" }
_Layout页面配置
<body> <div id="app"> @RenderBody() <div id="blazor-error-ui"> <environment include="Staging,Production"> An error has occurred. This application may no longer respond until reloaded. </environment> <environment include="Development"> An unhandled exception has occurred. See browser dev tools for details. </environment> <a href="" class="reload">Reload</a> <a class="dismiss">🗙</a> </div> <script src="_framework/blazor.server.js" autostart="false"></script> <script> Blazor.start(); </script> <script src="_content/MudBlazor/MudBlazor.min.js?v=5.0.5"></script> <script src="js/scroll.js"></script> <script src="js/sounds.js"></script> <script src="js/file.js"></script> <script src="js/script.js"></script>
求助
寻求有Azure App Service部署Blazor Server经验的人士提供排查方向。
内容的提问来源于stack exchange,提问作者ELA
相关产品推荐
相关产品推荐

