Configure SignalR To Show Detailed Errors And Fallback To Long Polling If WebSocket Dies (To Diagnose Clientside Connection Errors)
This commit is contained in:
parent
0b35f4e55e
commit
a7dda238ce
@ -24,7 +24,11 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddDbContext<DataContext>();
|
||||
builder.Services.AddSignalR();
|
||||
builder.Services.AddSignalR().AddHubOptions<ChatHub>(options =>
|
||||
{
|
||||
options.EnableDetailedErrors = true;
|
||||
options.KeepAliveInterval = TimeSpan.FromMinutes(1);
|
||||
});
|
||||
|
||||
builder.Services.AddStackExchangeRedisCache(options =>
|
||||
{
|
||||
@ -79,7 +83,11 @@ app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.MapHub<ChatHub>("/chat");
|
||||
app.MapHub<ChatHub>("/chat", options =>
|
||||
{
|
||||
options.Transports = Microsoft.AspNetCore.Http.Connections.HttpTransportType.WebSockets |
|
||||
Microsoft.AspNetCore.Http.Connections.HttpTransportType.LongPolling;
|
||||
});
|
||||
app.MapHub<TicTacToeHub>("/tttgame");
|
||||
|
||||
app.Run();
|
||||
|
Loading…
x
Reference in New Issue
Block a user