I have an application written in Blazor WebAssembly under .Net8. This app is hosted model which means that has a client and server project. For the intercommunication web api is used. The app is using signalr hubs for broadcasting some messages to all users and all user’s tabs.
The Server Program.cs file:
builder.Services.AddSignalR(hubOptions =>
{
hubOptions.ClientTimeoutInterval = TimeSpan.FromMinutes(30);
hubOptions.KeepAliveInterval = TimeSpan.FromMinutes(15);
});
//........
app.MapHub<ChatHub>("hubs/chathub");
On the Client page, under Index razor component:
hubConnection = new HubConnectionBuilder()
.WithUrl(navigationManager.ToAbsoluteUri("/hubs/chathub"))
.WithAutomaticReconnect()
.Build();
This gives various errors on page loading while replicas are grater than one into Kubernetes cluster, i have done already some expirements:
-
When using options.Transports =
Microsoft.AspNetCore.Http.Connections.HttpTransportType.WebSockets;
Then error is: WebSocket connection to ‘ws://www,xxx.com/hubs/myhub’
failed -
When using options.Transports =
Microsoft.AspNetCore.Http.Connections.HttpTransportType.ServerSentEvents;
Then error is: Unhandled exception rendering component:
ServerSentEvents can not be the only transport specified when
running in the browser -
When using options.Transports =
Microsoft.AspNetCore.Http.Connections.HttpTransportType.LongPolling;
Then error is: LongPolling failed:
net_http_message_not_success_statuscode_reason, 404, Not Found
I am trying to sync messages across servers in order not to centralize the the signalr service into an another independent pod. Any ideas?