We have a net5.0 console project running a SignalR client with a net5.0 webserver hosting a SignalR server. There is no authentication required on the server. Once an hour, the client thrown an exception.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
At that same time, the server is throwing a 404 on a POST to the SignalR Hub. Example below:
http://xxxxx/LineHub?id=NysqhPnGO1wgF5YTG1cWJw
Here is how the client connection is built:
var connection = new HubConnectionBuilder()
.WithUrl(lineHubUrl)
.ConfigureLogging(s =>
{
s.SetMinimumLevel(LogLevel.Debug);
s.AddFilter("Microsoft.AspNetCore.SignalR", LogLevel.Debug);
s.AddFilter("Microsoft.AspNetCore.Http.Connections", LogLevel.Debug);
s.AddApplicationInsights(configuration.GetValue<string>("ApplicationInsights:InstrumentationKey"));
})
.WithAutomaticReconnect(new RandomRetryPolicy())
.Build();
The server configuration is as follows:
services.AddSignalR(options =>
{
options.MaximumReceiveMessageSize = null;
options.EnableDetailedErrors = true;
options.ClientTimeoutInterval = TimeSpan.FromMinutes(1);
options.HandshakeTimeout = TimeSpan.FromMinutes(1);
});
We do have logic to restart the connection and it does so successfully but messages to the SignalR server fail if they happen to be sent while reconnecting.