MaxHubServerConnectionCount being ignored and server connections exceeding what they are set to
bkatchmar opened this issue · comments
Describe the bug
I am trying to switch a project to use Azure SignalR from Redis. The documentation and debugging through localhost are all fine. But I am trying to begin testing on a dev environment. We have two MVC servers
- dev-mvc
- dev-mvc2
We use a load balancer in this environment as that is what we use in a production environment. Since this is dev, we are using the free tier, I am aware of the 20 concurrent connections limit. Due to this and the limited use of dev environment, I am setting things to fairly low values. I initiate Azure SignalR via these lines of code
builder.Services
.AddSignalR(hubOptions =>
{
hubOptions.EnableDetailedErrors = true;
hubOptions.KeepAliveInterval = TimeSpan.FromSeconds(3);
})
.AddAzureSignalR(azureOptions =>
{
azureOptions.ConnectionString = AppConfiguration.Azure.SignalRConnectionString;
azureOptions.ApplicationName = $"{AppConfiguration.Azure.SignalRApplicationName}_{Environment.MachineName.ToLower().Replace("-", "_")}"; // This is different between dev-mvc and dev-mvc2
azureOptions.MaxHubServerConnectionCount = 5;
})
.AddNewtonsoftJsonProtocol(options =>
{
options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});
......
app.MapHub<NotificationHub>("/notifications");
As you can see, we only have 1 hub class. So at max, 1 server is online, we should only see 5 max server connections. Since we use 2 MVC servers, I am lead to believe the max number of server connections should only be 10. However, this is not the case. As soon as the MVC servers are turned on, I can verify this via a status end point I use to assure connections are good, the dashboard on Azure almost immediately switches from 0 server connections to 20.
I tried another experiment where I turn one MVC server offline (I keep the load balancer on) and at first, the server connections are reported as 5. However, after a minute, the number jumps to 10, then 15, and even though we only are using one MVC server, it eventually balloons to 20 despite explicitly setting MaxHubServerConnectionCount
to 5.
Is it possible I am not understanding things correctly or some other setting I need to play around with?
It appears setting InitialHubServerConnectionCount
explicitly was necessary to keep the number of sever connections per hub class controlled.