我有一个ASP.NET 6.0 Core Web Api with Signalr发布到Windows Server 2017上的IIS. 然后我有一个React-Native移动应用程序,它使用@microsoft/signalr连接到SignalR中心. 当移动应用程序通过Android模拟器和我的Android手机在调试模式下运行时,它可以连接到Signalr,没有任何问题. 一切都很完美. 现在,当我try 在发布模式下运行相同的应用程序时,它不工作,也无法连接. 任何 idea /帮助将不胜感激.
Program.cs Main
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
//.AllowCredentials()
//.SetIsOriginAllowed((host) => true);
});
}
);
// Add services to the container.
builder.Services.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
//options.JsonSerializerOptions.PropertyNamingPolicy = null;
});
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSignalR();
builder.Logging.ClearProviders();
Serilog.ILogger logger = new AppLogger(builder.Configuration).Logger;
builder.Logging.AddSerilog(logger, true);
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment() || app.Environment.IsProduction())
{
app.UseSwagger();
app.UseSwaggerUI();
}
//app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();
app.UseCors();
app.UseWebSockets();
app.MapControllers();
app.MapHub<FacilityHub>("/facility-hub");
app.Run();
我运行了以下命令,查看应用程序在发布模式下运行时的日志(log).
NPX REACT-本机日志(log)-Android
NPX REACT-本机运行-Android-模式发布
Here is the error in the logs when mobile app is running is release mode.
Here is the error in the logs when mobile app is running is debug mode.