admin管理员组文章数量:1287973
I have a couple of strange problems with the Blazor server running on IIS.
Getting error: Error: Connection disconnected with error 'Error: Server timeout elapsed without receiving a message from the server.'. This happens on all servers, i.e., IIS, IIS Express and Kestrel. However, using a Blazor server template application doesn't have the timeout issue.
Running Kestrel for development, the browser has the connection closed on the SSL port but works on the HTTP port with the error: https://localhost:5101/my-tags This site can’t be reached localhost unexpectedly closed the connection. This happens on the template application for Kelstrel on https as well.
I am kind of at witts end. #1 is causing problems in production, whereas #2 is just a minor pain but could be related.
Here are the launch settings:
"profiles": {
"JBFTags": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "my-tags?login=jMVt+ABJXf87QX52eeGLOGAnA6BPYUPMnoqaZUiVvoc=",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:5101;http://localhost:5100"
},
"JBFTagshttponly": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "my-tags?login=jMVt+ABJXf87QX52eeGLOGAnA6BPYUPMnoqaZUiVvoc=",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5100"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "my-tags?login=m57T6dYR2EjA==",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
},
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:19716",
"sslPort": 44396
}
}
}
Here is the program.cs
using NLog;
var logger = NLog.LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
logger.Info("JBF Web App started!");
var builder = WebApplication.CreateBuilder(args);
try
{
// file gets locked so close it in case it's open
try
{
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Telerik Reporting", "WebReportDesignerSettings.json");
File.Create(path).Close();
}
catch (Exception ex)
{
logger.Warn("Path error: {0}", ex.Message);
}
// Add services to the container.
builder.Services.AddCors(c =>
{
c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
});
builder.Services.AddScoped<SizeService>();
builder.Services.AddServerSideBlazor()
.AddHubOptions(options =>
{
options.ClientTimeoutInterval = TimeSpan.FromMinutes(2); // Client timeout
options.HandshakeTimeout = TimeSpan.FromMinutes(2); // Handshake timeout
options.KeepAliveInterval = TimeSpan.FromMinutes(1); // Keep-alive interval
});
builder.Services.AddScoped<DialogService>();
builder.Services.AddScoped<NotificationService>();
builder.Services.AddScoped<TooltipService>();
builder.Services.AddScoped<ContextMenuService>();
builder.Services.AddScoped<IMyIdService, MyIdService>();
builder.Services.AddScoped<SelectedTagsService>();
builder.Services.AddScoped<JSServices>();
builder.Services.AddScoped<ICookieService, CookieService>();
builder.Services.AddHttpContextAccessor();
builder.Services.AddSingleton<UserAgentDetecter>();
builder.Services.AddSingleton<HostService>();
builder.Services.AddSingleton<ExportService>();
builder.Services.AddSingleton<TagsSqlService>();
builder.Services.AddScoped<IIdentitySQLService, IdentitySQLService>();
builder.Services.AddScoped<ToasterService>();
builder.Services.AddScoped<ITagsEFRepo, TagsEFRepo>();
builder.Services.AddScoped<IAspNetEfRepo, AspNetEfRepo>();
builder.Services.AddControllers();
builder.Services.AddRazorPages().AddNewtonsoftJson();
builder.Services.AddDbContext<TagDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("JBFSqlServer2005")));
builder.Services.AddDbContext<AspNetDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("JBFASPNETDB")));
var reportsPath = Path.Combine(builder.Environment.ContentRootPath, "Reports");
// Configure dependencies for ReportsController.
builder.Services.TryAddSingleton<IReportServiceConfiguration>(sp =>
new ReportServiceConfiguration
{
ReportingEngineConfiguration = sp.GetService<IConfiguration>(),
HostAppId = "JBFTags",
Storage = new FileStorage(),
ReportSourceResolver = new TypeReportSourceResolver()
.AddFallbackResolver(new UriReportSourceResolver(reportsPath))
});
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowBlazorOrigin", builder =>
{
builder.WithOrigins("http://localhost:5000", "https://localhost:5001")
.AllowAnyHeader()
.AllowAnyMethod();
});
});
// Configure dependencies for ReportDesignerController.
builder.Services.TryAddSingleton<IReportDesignerServiceConfiguration>(sp => new ReportDesignerServiceConfiguration
{
DefinitionStorage = new FileDefinitionStorage(reportsPath, new[] { "Resources", "Shared Data Sources" }),
ResourceStorage = new ResourceStorage(Path.Combine(reportsPath, "Resources")),
SharedDataSourceStorage = new FileSharedDataSourceStorage(Path.Combine(reportsPath, "Shared Data Sources")),
SettingsStorage = new FileSettingsStorage(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Telerik Reporting"))
});
// NLog: Setup NLog for Dependency injection
builder.Logging.ClearProviders();
builder.Host.UseNLog();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseCors(options => options.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
app.UseCors("AllowBlazorOrigin");
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapControllers();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.UseWebSockets();
app.Run();
// Log the ports the application is listening on
logger.Info("listing ports");
var serverAddresses = app.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>();
foreach (var address in serverAddresses.Addresses)
{
logger.Info("Listening on: {0}", address);
}
}
catch (Exception e)
{
logger.Error(e, "Stopped program because of exception");
throw;
}
finally
{
NLog.LogManager.Shutdown();
}
Netstat output and OS Version TCP 127.0.0.1:5100 0.0.0.0:0 LISTENING *** HTTP TCP 127.0.0.1:5101 0.0.0.0:0 LISTENING *** HTTPS
$ systeminfo | grep OS OS Name: Microsoft Windows Server 2022 Standard OS Version: 10.0.20348 N/A Build 20348 OS Manufacturer: Microsoft Corporation OS Configuration: Standalone Server OS Build Type: Multiprocessor Free BIOS Version: Proxmox distribution of EDK II 4.2023.08-4, 2/15/2024
版权声明:本文标题:Blazor Server running on IIS causing network connection problems in Windows Server 2022 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741332063a2372820.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论