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, as there would be more server instances, i have done already some experiments:
When using
options.Transports = Microsoft.AspNetCore.Http.Connections.HttpTransportType.WebSockets;Then error is: WebSocket connection to 'ws://www,xxx.com/hubs/myhub'failedWhen using
options.Transports = Microsoft.AspNetCore.Http.Connections.HttpTransportType.ServerSentEvents;Then error is: Unhandled exception rendering component:ServerSentEvents can not be the only transport specified whenrunning in the browserWhen 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 (not having a central broker) into an another independent pod. Any ideas?