We have a SignalR hub called StatusUpdateHub. This hub is updated by a .NET client called HubClient. This client will be (in production), called several thousand times per second by several users for different transactions. Here is the client code:
public static class HubClient { private static readonly string statusUpdateUrl = ConfigurationManager.AppSettings["StatusUpdateUrl"]; private static readonly HubConnection connection = new HubConnection(statusUpdateUrl); private static readonly IHubProxy hub = connection.CreateProxy("StatusUpdateHub"); internal static void UpdateBrowser(long transactionId) { connection.Start().ContinueWith(task => hub.Invoke("UpdateTransactionStatus", transactionId)).ContinueWith(task => { if (task.IsFaulted && task.Exception != null) {
When this code is called with 100 concurrent users, it works fine, but when we increase the number of concurrent users to 250, we see the following error:
Unexpected error in UpdateBrowser: System.InvalidOperationException: Connection failed. in SignalR.Client.Connection.SignalR.Client.IConnection.Send [T] (Data String) in SignalR.Client.Hubs.HubProxy.Invoke [T] (String method, Object [] args) in SignalR.Client.Hubs. HubProxy.Invoke (String method, Object [] args) with Application.Services.HubClient <. > C_DisplayClass2.b_0 (Task task1) in c: \ Build \ Work \ Application \ Services \ HubClient.cs: line 20
in System.Threading.Tasks.Task`1.InvokeFuture (Object futureAsObj)
in System.Threading.Tasks.Task.Execute ()
Let us know how to make the code more scalable?
Achinth gurkhi
source share