I am working on a microservices project with a hosted blazor webassembly application all in a kubernetes cluster. In the Blazor Webassembly (Hosted) PWA I am using SignalR Hub for the communication between the Blazor.Client and Blazor.Server. When I call HubConnection.StartAsync sometimes it lasts a few milliseconds and sometimes up to 15 seconds.
Usage and StartAsync-Call in Blazor.Client:
var hubConnection = new HubConnectionBuilder()
.WithUrl( Navigator.ToAbsoluteUri( "/testhub" ), options =>
{
options.Transports = HttpTransportType.WebSockets;
options.SkipNegotiation = true;
})
.WithAutomaticReconnect()
.Build();
hubConnection.On<MyDataModel>( "ReceiveData", ( result ) => HandleData( result ) );
try
{
// !! sometimes this call lasts up to 15 seconds !!
await hubConnection.StartAsync();
}
catch (OperationCanceledException) { }
SignalR configuration in Program.cs in Blazor.Server:
builder.Services.AddSignalR( options =>
{
options.ClientTimeoutInterval = TimeSpan.FromSeconds( 60 );
options.HandshakeTimeout = TimeSpan.FromSeconds( 30 );
options.MaximumParallelInvocationsPerClient = 3;
options.KeepAliveInterval = TimeSpan.FromSeconds( 5 );
options.EnableDetailedErrors = true;
} );
// Response compression for SignalR
builder.Services.AddResponseCompression( opts =>
{
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
new[] { "application/octet-stream" } );
} );
I played around with the configuration but with no effect. On my local workstation there is no problem, but deployed to the cloud this problem occurs. What can be the reason for this problem?
Update:
I found out that this problem occurs in chrome/edge browsers and not in firefox.