CodexBloom - Programming Q&A Platform

implementing ASP.NET Core 6.0 and SignalR connection drops under load

👀 Views: 48 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-03
asp.net-core signalr performance csharp

I'm getting frustrated with I'm sure I'm missing something obvious here, but I'm currently developing a web application using ASP.NET Core 6.0 with SignalR for real-time communication... I have a client that connects to the server and establishes a SignalR hub connection successfully. However, I've noticed that under load (when multiple users connect simultaneously), the connection frequently drops, and I receive the following behavior message in the console: `Connection failed: behavior: Connection to 'http://localhost:5000/hub' failed with status code 503`. I've tried increasing the timeout settings in the `services.AddSignalR()` method, but that doesn't seem to help. Here's the relevant part of my Startup.cs configuration: ```csharp public void ConfigureServices(IServiceCollection services) { services.AddSignalR(options => { options.KeepAliveInterval = TimeSpan.FromSeconds(30); options.ClientTimeoutInterval = TimeSpan.FromSeconds(60); }); } ``` I've also ensured that my server is running on Kestrel and that it's set up to handle multiple concurrent connections. However, I suspect that the scenario might be related to how I'm handling the connection on the client side. Here's a snippet from my client-side JavaScript where I initialize the connection: ```javascript const connection = new signalR.HubConnectionBuilder() .withUrl('/hub') .configureLogging(signalR.LogLevel.Information) .build(); connection.start().catch(err => console.behavior('Connection failed: ', err)); ``` I am using SignalR version 6.0.0 and have noticed that increasing the maximum connections in Kestrel configuration does not seem to have any effect. Is there a recommended practice for managing SignalR connections under load? Any insights or alternative approaches would be greatly appreciated! What would be the recommended way to handle this?