What is the best way to load test a SignalR hubs application?

asp.net-4.0, asp.net-mvc, signalr

Solution

In short, if using Hubs, using the .Net client will suffice.

In my case, I have a newsfeed hub that dishes out client-specific data based on the user's profile ID. In my test case, I load up a bunch of profile ID's (6000 in this case), invoke a hub method called JoinNewsfeed() along with the client-specific connection ID and profile ID. Every 100ms a new connection is established.

    [TestMethod]
    public void TestJoinNewsfeedHub()
    {
        int successfulConnections = 0;

        // get profile ID's
        memberService = new MemberServiceClient();
        List<int> profileIDs = memberService.GetProfileIDs(6000).ToList<int>();

        HubConnection hubConnection = new HubConnection(HUB_URL);
        IHubProxy newsfeedHub = hubConnection.CreateProxy("NewsfeedHub");


        foreach (int profileID in profileIDs)
        {
            hubConnection.Start().Wait();
            //hubConnection = EstablishHubConnection();
            newsfeedHub.Invoke<string>("JoinNewsfeed", hubConnection.ConnectionId, profileID).ContinueWith(task2 =>
            {
                if (task2.IsFaulted)
                {
                    System.Diagnostics.Debug.Write(String.Format("An error occurred during the method call {0}", task2.Exception.GetBaseException()));
                }
                else
                {
                    successfulConnections++;
                    System.Diagnostics.Debug.Write(String.Format("Successfully called MethodOnServer: {0}", successfulConnections));

                }
            });

            Thread.Sleep(100);

        }

        Assert.IsNotNull(newsfeedHub);
    }

Performance metrics listed here do the trick on the server. To ensure that a client has in fact connected and the process of populating client object on the server has successfully completed, I have a server-side method that invokes a client-side function with the number and list of connected clients derived from the connected client collection.

Problem

I would like to know some of the different methods that have been used to test a SignalR hubs-based application.

Original source