We are using Blazor and SignalR to create a websocket connection between the client and our server. On all systems we see that every 30 seconds an error is logged to the console:
This_console_error:7 fail: Microsoft.AspNetCore.SignalR.Client.HubConnection[69] HubConnection reconnecting due to an error. System.TimeoutException: Server timeout (30000.00ms) elapsed without receiving a message from the server. _bound_js_globalThis_console_err
We are setting up the connection on the client side like this:
HubConnection hubConnection = new HubConnectionBuilder()
.WithUrl(navigationManager.ToAbsoluteUri(HubConstants.TransportPackages),
options => {
options.AccessTokenProvider = () => Task.FromResult(authenticationService?.User?.Token);
options.Transports = Microsoft.AspNetCore.Http.Connections.HttpTransportType.WebSockets | Microsoft.AspNetCore.Http.Connections.HttpTransportType.ServerSentEvents | Microsoft.AspNetCore.Http.Connections.HttpTransportType.LongPolling;
})
.ConfigureLogging(logging => {
logging.AddProvider(loggerProvider);
})
.WithAutomaticReconnect()
.Build();
hubConnection.On(HubConstants.ReceiveTransportPackage, handler);
await hubConnection.StartAsync();
if we remove ".WithAutomaticReconnect()" then the error message is different:
fail: Microsoft.AspNetCore.SignalR.Client.HubConnection[12] Connection is shutting down due to an error. System.TimeoutException: Server timeout (30000.00ms) elapsed without receiving a message from the server.
It looks like the error is logged because of the timeout setting (on the server?). But why is it logged as an error? Is this by design or are we doing something wrong?
We know that if we remove "logging.AddProvider(loggerProvider);" the error will not be logged anymore, but we still want to have other logs messages.