Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Performance problem using long polling with many clients #2125

Closed
RichardW1001 opened this Issue · 10 comments

4 participants

Richard Wellum David Fowler Gustavo Armenta N. Taylor Mullen
Richard Wellum

Using the HubConnectionAPI sample, slightly modified as follows. This is hosted in an Azure cloud service.

  • In the javascript, when a disconnect occurs it will kick off a randomized timer to reconnect the client
  • It broadcasts a message to all clients every 10 seconds
  • Removed the broadcasts in OnConnected, OnReconnected, OnDisconnected.

Using PhantomJs, I created 900 clients that navigate to this page adding '?transport=longPolling' to the end of the url to force long polling. (150 instances per VM, 6 large VMs in Azure)

All 900 clients connect cleanly and the processor load on the server is fairly low.

I then stop IIS on the server, wait for 3 minutes, then start IIS. The processor load then shoots up to 100% and pretty well stays there. See the attached image. The spikes on the left correspond to the broadcasts every 10 seconds, growing larger as more clients connect. The low processor usage in the middle is when IIS is stopped. The 100% processor usage area on the right is when I restart IIS. It doesn't matter how long I leave it, the processor time usage will never reduce, but the clients all still seem to work.

cpuprofile
I attached a debugger while IIS was stopped, so have a log file which shows the 900 clients reconnecting which is available here http://sdrv.ms/Zyp1TI There are also two dotTrace files available there, but they didn't really give me any clues.

The changes to HubConnectionAPI.js are as follows. Notice that the call to $.connection.hub.start is factored out into a function which is called from a timer in the handler for $.connection.hub.disconnected

/// <reference path="../../Scripts/jquery-1.8.2.js" />
$(function () {
    "use strict";

    var hubConnectionAPI = $.connection.hubConnectionAPI,
        messages = $("#messages"),
        groupNameTextInput = $("#group"),
        connectionTextInput = $("#connection"),
        messageTextInput = $("#message"),
        groupMessageTextInput = $("#groupMessage"),
        meTextInput = $("#me"),
        stopStartBtn = $("#stopStart"),
        start;

    $.connection.hub.logging = true;

    hubConnectionAPI.client.displayMessage = function (value) {
        $("<li/>").html("[" + new Date().toTimeString() + "]: " + value).appendTo(messages);
    }

    $.connection.hub.stateChanged(function (change) {
        var oldState = null,
            newState = null;

        for (var state in $.signalR.connectionState) {
            if ($.signalR.connectionState[state] === change.oldState) {
                oldState = state;
            } else if ($.signalR.connectionState[state] === change.newState) {
                newState = state;
            }
        }

        $("<li/>").html("[" + new Date().toTimeString() + "]: " + oldState + " => " + newState + " " + $.connection.hub.id)
                    .appendTo(messages);
    });

    $.connection.hub.reconnected(function () {
        $("<li/>").css("background-color", "green")
                    .css("color", "white")
                    .html("[" + new Date().toTimeString() + "]: Connection re-established")
                    .appendTo(messages);
        $("<li/>").html("reconnected transport: " + $.connection.hub.transport.name + " " + $.connection.hub.id)
                    .appendTo(messages);
    });

    $.connection.hub.error(function (err) {
        $("<li/>").html("Error occurred: " + err).appendTo(messages);
    });

    $.connection.hub.connectionSlow(function () {
        $("<li/>").html("[" + new Date().toTimeString() + "]: Connection Slow").appendTo(messages);
    });

    var reconnectTimeoutHandle = null;
    $.connection.hub.disconnected(function () {
        stopStartBtn.prop("disabled", false)
                    .find("span")
                        .text("Start Connection")
                        .end()
                    .find("i")
                        .removeClass("icon-stop")
                        .addClass("icon-play");
        window.clearTimeout(reconnectTimeoutHandle);
        reconnectTimeoutHandle = window.setTimeout(start, (Math.random() * 10000) + 2000);
    });

    start = function () {
        $.connection.hub.start({ transport: activeTransport, jsonp: isJsonp })
            .done(function () {
                $("<li/>").html("started transport: " + $.connection.hub.transport.name + " " + $.connection.hub.id)
                            .appendTo(messages);

                stopStartBtn.prop("disabled", false)
                            .find("span")
                                .text("Stop Connection")
                                .end()
                            .find("i")
                                .removeClass("icon-play")
                                .addClass("icon-stop");
            });
    };
    start();


    $('#joinGroup').click(function () {
        // Set the connection Id to the specified value or the generated SignalR value
        var connectionIdToJoin = connectionTextInput.val() || $.connection.hub.id;

        hubConnectionAPI.server.joinGroup(connectionIdToJoin, groupNameTextInput.val()).done(function (value1) {
            $("<li/>").html("Succeeded at joinGroup: " + value1).appendTo(messages);
        }).fail(function (e) {
            $("<li/>").html("Failed at joinGroup: " + e).appendTo(messages);
        });
    });

    $('#leaveGroup').click(function () {
        // Set the connection Id to the specified value or the generated SignalR value
        var connectionIdToLeave = connectionTextInput.val() || $.connection.hub.id;

        hubConnectionAPI.server.leaveGroup(connectionIdToLeave, groupNameTextInput.val()).done(function (value1) {
            $("<li/>").html("Succeeded at leaveGroup: " + value1).appendTo(messages);
        }).fail(function (e) {
            $("<li/>").html("Failed at leaveGroup: " + e).appendTo(messages);
        });
    });

    $("#broadcast").click(function () {
        hubConnectionAPI.server.displayMessageAll(messageTextInput.val()).fail(function (e) {
            $("<li/>").html("Failed at getMessage: " + e).appendTo(messages);
        });
    });

    $("#broadcastExceptSpecified").click(function () {
        hubConnectionAPI.server.displayMessageAllExcept(messageTextInput.val(), connectionTextInput.val().split(",")).fail(function (e) {
            $("<li/>").html("Failed at getMessageAllExcept: " + e).appendTo(messages);
        });
    });


    $("#other").click(function () {
        hubConnectionAPI.server.displayMessageOther(messageTextInput.val()).fail(function (e) {
            $("<li/>").html("Failed at getMessageOther: " + e).appendTo(messages);
        });
    });


    $("#sendToMe").click(function () {
        hubConnectionAPI.server.displayMessageCaller(meTextInput.val()).fail(function (e) {
            $("<li/>").html("Failed at getMessageCaller: " + e).appendTo(messages);
        });
    });


    $("#specified").click(function () {
        hubConnectionAPI.server.displayMessageSpecified(connectionTextInput.val(), meTextInput.val()).fail(function (e) {
            $("<li/>").html("Failed at getMessageSpecified: " + e).appendTo(messages);
        });
    });

    $("#groupmsg").click(function () {
        hubConnectionAPI.server.displayMessageGroup(groupNameTextInput.val(), groupMessageTextInput.val()).fail(function (e) {
            $("<li/>").html("Failed at getMessageGroup: " + e).appendTo(messages);
        });
    });

    $("#groupmsgExceptSpecified").click(function () {
        hubConnectionAPI.server.displayMessageGroupExcept(groupNameTextInput.val(), groupMessageTextInput.val(), connectionTextInput.val().split(",")).fail(function (e) {
            $("<li/>").html("Failed at displayMessageGroupExcept: " + e).appendTo(messages);
        });
    });

    $("#otherInGroupmsg").click(function () {
        hubConnectionAPI.server.displayMessageOthersInGroup(groupNameTextInput.val(), groupMessageTextInput.val()).fail(function (e) {
            $("<li/>").html("Failed at displayMessageOthersInGroup: " + e).appendTo(messages);
        });
    });

    stopStartBtn.click(function () {
        var $el = $(this);

        $el.prop("disabled", true);

        if ($.trim($el.find("span").text()) === "Stop Connection") {
            $.connection.hub.stop();
        } else {
            start();
        }
    });
});

The changes to HubConnectionAPI.cs are as follows. Notice the removal of the OnConnected, OnDisconnected and OnReconnected overrides, and the addition of a few static bits to send a message every 10 seconds.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Timers;
using System.Linq;
using System.Collections.Concurrent;
using System.IO;

namespace Microsoft.AspNet.SignalR.Hosting.AspNet.Samples.Hubs.HubConnectionAPI
{
    public class PingData
    {
        public string connId;
        public DateTime date;
    }

    public class HubConnectionAPI : Hub
    {
        static IHubContext context;
        static Timer t;
        static HubConnectionAPI()
        {
            t = new Timer(10000);
            t.Elapsed += SendMessage;
            t.Start();
            context = GlobalHost.ConnectionManager.GetHubContext<HubConnectionAPI>();
        }

        static void SendMessage(object sender, ElapsedEventArgs e)
        {
            context.Clients.All.displayMessage("Hello");
        }

        public string JoinGroup(string connectionId, string groupName)
        {
            Groups.Add(connectionId, groupName).Wait();
            return connectionId + " joined " + groupName;
        }

        public string LeaveGroup(string connectionId, string groupName)
        {
            Groups.Remove(connectionId, groupName).Wait();
            return connectionId + " removed " + groupName;
        }

        public void DisplayMessageAll(string message)
        {
            Clients.All.displayMessage("Clients.All: " + message + " from " + Context.ConnectionId);
        }

        public void DisplayMessageAllExcept(string message, params string[] excludeConnectionIds)
        {
            Clients.AllExcept(excludeConnectionIds).displayMessage("Clients.AllExcept: " + message + " from " + Context.ConnectionId);
        }

        public void DisplayMessageOther(string message)
        {
            Clients.Others.displayMessage("Clients.Others: " + message + " from " + Context.ConnectionId);
        }

        public void DisplayMessageCaller(string message)
        {
            Clients.Caller.displayMessage("Clients.Caller: " + message + " from " + Context.ConnectionId);
        }

        public void DisplayMessageSpecified(string targetConnectionId, string message)
        {
            Clients.Client(targetConnectionId).displayMessage("Clients.Client: " + message + " from " + Context.ConnectionId);
        }

        public void DisplayMessageGroup(string groupName, string message)
        {
            Clients.Group(groupName).displayMessage("Clients.Group: " + message + " from " + Context.ConnectionId);
        }

        public void DisplayMessageGroupExcept(string groupName, string message, params string[] excludeConnectionIds)
        {
            Clients.Group(groupName, excludeConnectionIds).displayMessage("Clients.Group: " + message + " from " + Context.ConnectionId);
        }

        public void DisplayMessageOthersInGroup(string groupName, string message)
        {
            Clients.OthersInGroup(groupName).displayMessage("Clients.OthersInGroup: " + message + " from" + Context.ConnectionId);
        }
    }
}
David Fowler davidfowl was assigned
David Fowler
Owner

@chenriks let's try to get a repro of this. @RichardW1001 can you share your harness?

Richard Wellum

@davidfowl - I've put a copy of the load test project up on skydrive http://sdrv.ms/Zyp1TI. The worker role will create 150 instances of PhantomJS - this should be fine on a large Azure instance. You will need to change the URL in TestScript.js.

Also, during testing I noticed that when the server is under load there is a problem in the javascript where multiple long polls are set up on reconnect. This is simply fixed by making the following changes in jquery.signalR-1.1.2.js:

line 1580 add:
startTimerHandle = null;

line 1654 change:
window.setTimeout(function () {
to:
window.clearTimeout(startTimerHandle);
startTimerHandle = window.setTimeout(function () {

Richard Wellum

Update:

When this problem occurs some of the clients get themselves into a loop where the long poll is constantly being re-established. Inspection of the HTTP response shows that the messages array is empty.

As a temporary workaround I added this code to the javascript on line 1705 (after data = transportLogic.maximizePersistentResponse(minData);:

if (!data.Disconnect && !data.TimedOut && !data.LongPollDelay && !data.GroupsToken && data.Messages.length == 0) {
connection.log("DETECTED SIGNALR INFINITE LOOP; RELOADING PAGE");
window.location.reload();
}

Although this is obviously a big hairy hack, it completely fixes the problem.

Interestingly this shows that the problem doesn't only exist on reconnect, but also to a lesser extent, on initial connect.

David Fowler
Owner

Is your test sample broadcasting to all clients?

Richard Wellum

Yes - it's broadcasting to all clients. The line from HubConnectionAPI.cs that does it is:

context.Clients.All.displayMessage("Hello");

Here's a log file from a client when it goes into its crazy loop:

[11:19:02 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=mXlYa0XGy_qMF_A4BNR2nGS-StQui4EOetUES-YOP2C3oVg1__B03GHkSbzQ4Ek24WbRyS5_8kdDysCVT0UbxVLNw8jtZ52qFXpMzzWlGrA19S_l0&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C145%7CCNl%2C0%7CCNm%2C0%7CCNn%2C0&tid=3' using longPolling.
[11:19:12 GMT+0000 (UTC)] SignalR: Triggering client hub event 'displayMessage' on hub 'HubConnectionAPI'.
[11:19:12 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=mXlYa0XGy_qMF_A4BNR2nGS-StQui4EOetUES-YOP2C3oVg1__B03GHkSbzQ4Ek24WbRyS5_8kdDysCVT0UbxVLNw8jtZ52qFXpMzzWlGrA19S_l0&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C146%7CCNl%2C0%7CCNm%2C0%7CCNn%2C0&tid=1' using longPolling.
[11:19:22 GMT+0000 (UTC)] SignalR: Triggering client hub event 'displayMessage' on hub 'HubConnectionAPI'.
[11:19:22 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=mXlYa0XGy_qMF_A4BNR2nGS-StQui4EOetUES-YOP2C3oVg1__B03GHkSbzQ4Ek24WbRyS5_8kdDysCVT0UbxVLNw8jtZ52qFXpMzzWlGrA19S_l0&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C147%7CCNl%2C0%7CCNm%2C0%7CCNn%2C0&tid=3' using longPolling.

IIS stopped here.

[11:20:03 GMT+0000 (UTC)] SignalR: An error occurred using longPolling. Status = error.
[11:20:03 GMT+0000 (UTC)] SignalR: SignalR: Initializing long polling connection with server.
[11:20:33 GMT+0000 (UTC)] SignalR: Couldn't reconnect within the configured timeout (30000ms), disconnecting.
[11:20:40 GMT+0000 (UTC)] SignalR: Negotiating with '/signalr/negotiate'.
[11:21:18 GMT+0000 (UTC)] SignalR: SignalR: Server ping failed because 'SignalR: Error pinging server: error', re-trying ping.

IIS started somewhere here


[11:21:26 GMT+0000 (UTC)] SignalR: SignalR: Initializing long polling connection with server.
[11:21:26 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/reconnect?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&tid=1' using longPolling.
[11:21:26 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/connect?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&tid=5' using longPolling.
[11:21:27 GMT+0000 (UTC)] SignalR: Longpolling connected
[11:21:28 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=9' using longPolling.
[11:21:28 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=1' using longPolling.
[11:21:28 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=0' using longPolling.
[11:21:29 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=5' using longPolling.
[11:21:29 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=6' using longPolling.
[11:21:30 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=0' using longPolling.
[11:21:30 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=1' using longPolling.
[11:21:30 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=7' using longPolling.
[11:21:31 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=0' using longPolling.
[11:21:32 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=0' using longPolling.
[11:21:33 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=6' using longPolling.
[11:21:34 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=9' using longPolling.
[11:21:34 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=5' using longPolling.
[11:21:35 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=3' using longPolling.
[11:21:35 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C0%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=8' using longPolling.
[11:21:36 GMT+0000 (UTC)] SignalR: Triggering client hub event 'displayMessage' on hub 'HubConnectionAPI'.
[11:21:36 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C1%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=0' using longPolling.
[11:21:36 GMT+0000 (UTC)] SignalR: Triggering client hub event 'displayMessage' on hub 'HubConnectionAPI'.
[11:21:36 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C1%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=4' using longPolling.
[11:21:38 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C1%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=5' using longPolling.
[11:21:38 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C1%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=3' using longPolling.
[11:21:39 GMT+0000 (UTC)] SignalR: Attempting to connect to 'http://bk-dac.cloudapp.net/signalr/poll?transport=longPolling&connectionToken=dsN160bDX91Y1KzW6dp-edHad2EYbraaHjQXEb8N4NouUAudl4a8WYXb1lqwKSYCyBuXMwyGZAxAl0kVCMh60Sw4II8_5LTR-R6hqmNWdA3TSZG40&connectionData=%5B%7B%22name%22%3A%22hubconnectionapi%22%7D%5D&messageId=B%2C1%7CM4%2C0%7CM5%2C0%7CM6%2C0&tid=10' using longPolling.

... ad infinitum.

As you can see it's still triggering the displayMessage method from time to time but most of the long poll results don't do anything.

Please let me know if there is any more information I can get for you.

Richard Wellum

Another problem that I see regularly in this scenario (but I don't always see it when the clients get into their loop) is a FormatException thrown from Cursors.cs, line 192:

// Don't allow duplicate keys
if (!signals.Add(currentKey))
{
    throw new FormatException(Resources.Error_InvalidCursorFormat);
}

The cursor string is B,1|C,0|D,0|E,0
currentKey is h-HubConnectionAPI
The string maximizer contains:

{[Bf, ack-e4cd4be5-cc89-4f5e-973c-ddb9fa43ee4d]}
{[BK, ack-1a67fbdf-1b15-4999-9701-bdd4235e8e55]}
{[Bs, hc-HubConnectionAPI.e664e9cb-52bf-4132-b44e-ded95be7101a]}
{[B7, hc-HubConnectionAPI.d5bd3e8e-ef9e-4551-8512-fd0491adfe88]}
{[B9, ack-d5bd3e8e-ef9e-4551-8512-fd0491adfe88]}
{[BL, hc-HubConnectionAPI.8aaeda9b-4788-48a2-a9fb-4897192969aa]}
{[Bb, c-a5cd1975-ab2f-423a-861e-2192274113a1]}
{[BW, ack-4a341189-44f9-4239-bf41-0565af9ad078]}
{[BY, c-5cdb277a-2ffc-40f3-b020-79b80d417bb8]}
{[B3, ack-f82aee8f-e54e-4895-a3db-d2637c0af8b0]}
{[CF, c-8b4aad74-de5f-4a36-b2b9-2c05ead89b78]}
{[BF, hc-HubConnectionAPI.7a9b9e4d-97f8-42e4-856e-abc0b47e3419]}
{[5, hc-HubConnectionAPI.384df830-e949-41ce-9e32-43816535b41c]}
{[BH, ack-7a9b9e4d-97f8-42e4-856e-abc0b47e3419]}
{[4, ack-1033c04f-643a-49d1-8e7a-35a1e118f9f6]}
{[7, ack-384df830-e949-41ce-9e32-43816535b41c]}
{[Bn, c-add4daa3-ac01-4b72-b218-2333feb7a9d7]}
{[6, c-384df830-e949-41ce-9e32-43816535b41c]}
{[1, ack-570874fd-84d4-4279-ac3b-139a33bd630b]}
{[0, c-570874fd-84d4-4279-ac3b-139a33bd630b]}
{[3, c-1033c04f-643a-49d1-8e7a-35a1e118f9f6]}
{[2, hc-HubConnectionAPI.1033c04f-643a-49d1-8e7a-35a1e118f9f6]}
{[BS, c-322f26ca-9bb9-4d29-aceb-07c71a4baa0a]}
{[Bq, c-02aee1d2-8ae5-4b42-8736-f0050b7416c0]}
{[9, c-3b4a11ae-d2b9-4dae-ade9-c96ad55e0e82]}
{[8, hc-HubConnectionAPI.3b4a11ae-d2b9-4dae-ade9-c96ad55e0e82]}
{[:, hc-HubConnectionAPI.bc2bb8b4-a979-46d4-ad0b-75af28af1ce1]}
{[B4, hc-HubConnectionAPI.67e04c36-49ce-4ec5-b0b8-020d814353d4]}
{[CB, hc-HubConnectionAPI.1a3cfe64-cdab-4eee-af9c-d76230c6f3f0]}
{[BB, ack-bc2bb8b4-a979-46d4-ad0b-75af28af1ce1]}
{[e, hc-HubConnectionAPI.5ffd63f4-c374-4c49-9b79-dc76fbd08a0a]}
{[d, ack-9ab2ac51-6a2b-4625-bc1a-fa36b4e36f2c]}
{[g, ack-5ffd63f4-c374-4c49-9b79-dc76fbd08a0a]}
{[f, c-5ffd63f4-c374-4c49-9b79-dc76fbd08a0a]}
{[a, ack-4c06b1f4-7514-4006-9e4c-10dc394262e6]}
{[BT, ack-322f26ca-9bb9-4d29-aceb-07c71a4baa0a]}
{[c, c-9ab2ac51-6a2b-4625-bc1a-fa36b4e36f2c]}
{[Bj, hc-HubConnectionAPI.e7ee57ba-78ff-4310-8a36-99ea3459abd7]}
{[b, hc-HubConnectionAPI.9ab2ac51-6a2b-4625-bc1a-fa36b4e36f2c]}
{[m, ack-256bba8c-8dff-4c86-be12-f4b052ed7b2e]}
{[l, c-256bba8c-8dff-4c86-be12-f4b052ed7b2e]}
{[o, c-68ecc62e-a9a1-4c00-a3af-8ecbb9d907ba]}
{[n, hc-HubConnectionAPI.68ecc62e-a9a1-4c00-a3af-8ecbb9d907ba]}
{[i, c-ed85c89f-b753-47e7-9950-659c51fbbbc9]}
{[B_, hc-HubConnectionAPI.06fc7efd-8316-41a7-a204-412124cf43ce]}
{[h, hc-HubConnectionAPI.ed85c89f-b753-47e7-9950-659c51fbbbc9]}
{[k, hc-HubConnectionAPI.256bba8c-8dff-4c86-be12-f4b052ed7b2e]}
{[j, ack-ed85c89f-b753-47e7-9950-659c51fbbbc9]}
{[u, c-5e38abe3-776c-45ce-9e89-d46273ee7fb5]}
{[t, hc-HubConnectionAPI.5e38abe3-776c-45ce-9e89-d46273ee7fb5]}
{[w, hc-HubConnectionAPI.284defe8-61de-4693-a467-8029c7a9139b]}
{[v, ack-5e38abe3-776c-45ce-9e89-d46273ee7fb5]}
{[q, hc-HubConnectionAPI.8b2b5a3f-ff80-41c7-8ef5-e5bed2c00834]}
{[p, ack-68ecc62e-a9a1-4c00-a3af-8ecbb9d907ba]}
{[s, ack-8b2b5a3f-ff80-41c7-8ef5-e5bed2c00834]}
{[r, c-8b2b5a3f-ff80-41c7-8ef5-e5bed2c00834]}
{[B0, ack-c7fa78fc-e041-4eee-8170-aa61e3f27cc9]}
{[y, ack-284defe8-61de-4693-a467-8029c7a9139b]}
{[x, c-284defe8-61de-4693-a467-8029c7a9139b]}
{[CG, ack-8b4aad74-de5f-4a36-b2b9-2c05ead89b78]}
{[z, hc-HubConnectionAPI.570874fd-84d4-4279-ac3b-139a33bd630b]}
{[E, hc-HubConnectionAPI.8d309b6f-706b-42ad-9e3b-5897b219422e]}
{[BG, c-7a9b9e4d-97f8-42e4-856e-abc0b47e3419]}
{[D, hc-HubConnectionAPI.6b6e752a-566a-4372-9eb1-3d72db5aa4eb]}
{[Be, c-e4cd4be5-cc89-4f5e-973c-ddb9fa43ee4d]}
{[G, c-8d309b6f-706b-42ad-9e3b-5897b219422e]}
{[F, c-6b6e752a-566a-4372-9eb1-3d72db5aa4eb]}
{[A, __SIGNALR__SERVER__]}
{[C, h-HubConnectionAPI]}
{[B, h-HubConnectionAPI]}
{[BN, ack-8aaeda9b-4788-48a2-a9fb-4897192969aa]}
{[M, hc-HubConnectionAPI.a41089f5-b92b-47a6-8e09-99cb4951487c]}
{[L, ack-35d98eb4-df15-4c06-8505-171c2d81c1dd]}
{[Bl, ack-e7ee57ba-78ff-4310-8a36-99ea3459abd7]}
{[O, ack-a41089f5-b92b-47a6-8e09-99cb4951487c]}
{[N, c-a41089f5-b92b-47a6-8e09-99cb4951487c]}
{[I, ack-8d309b6f-706b-42ad-9e3b-5897b219422e]}
{[H, ack-6b6e752a-566a-4372-9eb1-3d72db5aa4eb]}
{[K, c-35d98eb4-df15-4c06-8505-171c2d81c1dd]}
{[J, hc-HubConnectionAPI.35d98eb4-df15-4c06-8505-171c2d81c1dd]}
{[U, ack-5cf8e6de-691b-4bbe-87e4-f55de88021c6]}
{[T, c-5cf8e6de-691b-4bbe-87e4-f55de88021c6]}
{[W, c-c00b8bb0-943e-42bc-aaa4-257a56878085]}
{[V, hc-HubConnectionAPI.c00b8bb0-943e-42bc-aaa4-257a56878085]}
{[Q, c-7a7ba8bf-8a3d-4730-ab8d-8e97a1649d1d]}
{[P, hc-HubConnectionAPI.7a7ba8bf-8a3d-4730-ab8d-8e97a1649d1d]}
{[S, hc-HubConnectionAPI.5cf8e6de-691b-4bbe-87e4-f55de88021c6]}
{[R, ack-7a7ba8bf-8a3d-4730-ab8d-8e97a1649d1d]}
{[BP, c-349e1ecd-9bd6-4e4a-8281-009f5adeca6e]}
{[_, ack-3b4a11ae-d2b9-4dae-ade9-c96ad55e0e82]}
{[Bv, hc-HubConnectionAPI.a8091b49-b934-45ef-bd1d-b0ae32505cde]}
{[Y, hc-HubConnectionAPI.4c06b1f4-7514-4006-9e4c-10dc394262e6]}
{[X, ack-c00b8bb0-943e-42bc-aaa4-257a56878085]}
{[Z, c-4c06b1f4-7514-4006-9e4c-10dc394262e6]}
{[By, hc-HubConnectionAPI.c7fa78fc-e041-4eee-8170-aa61e3f27cc9]}
{[CC, c-1a3cfe64-cdab-4eee-af9c-d76230c6f3f0]}
{[BC, hc-HubConnectionAPI.0afd0453-d3fa-42a4-8dd2-94678cb18004]}
{[Ba, hc-HubConnectionAPI.a5cd1975-ab2f-423a-861e-2192274113a1]}
{[BJ, c-1a67fbdf-1b15-4999-9701-bdd4235e8e55]}
{[Bh, c-1e0f6761-106b-4123-afe3-b61c9c925518]}
{[Br, ack-02aee1d2-8ae5-4b42-8736-f0050b7416c0]}
{[B6, ack-67e04c36-49ce-4ec5-b0b8-020d814353d4]}
{[CE, hc-HubConnectionAPI.8b4aad74-de5f-4a36-b2b9-2c05ead89b78]}
{[BE, ack-0afd0453-d3fa-42a4-8dd2-94678cb18004]}
{[BO, hc-HubConnectionAPI.349e1ecd-9bd6-4e4a-8281-009f5adeca6e]}
{[Bm, hc-HubConnectionAPI.add4daa3-ac01-4b72-b218-2333feb7a9d7]}
{[BV, c-4a341189-44f9-4239-bf41-0565af9ad078]}
{[Bt, c-e664e9cb-52bf-4132-b44e-ded95be7101a]}
{[B2, c-f82aee8f-e54e-4895-a3db-d2637c0af8b0]}
{[CA, ack-06fc7efd-8316-41a7-a204-412124cf43ce]}
{[BA, c-bc2bb8b4-a979-46d4-ad0b-75af28af1ce1]}
{[Bg, hc-HubConnectionAPI.1e0f6761-106b-4123-afe3-b61c9c925518]}
{[Bi, ack-1e0f6761-106b-4123-afe3-b61c9c925518]}
{[BR, hc-HubConnectionAPI.322f26ca-9bb9-4d29-aceb-07c71a4baa0a]}
{[Bp, hc-HubConnectionAPI.02aee1d2-8ae5-4b42-8736-f0050b7416c0]}
{[Bz, c-c7fa78fc-e041-4eee-8170-aa61e3f27cc9]}
{[BM, c-8aaeda9b-4788-48a2-a9fb-4897192969aa]}
{[Bc, ack-a5cd1975-ab2f-423a-861e-2192274113a1]}
{[Bu, ack-e664e9cb-52bf-4132-b44e-ded95be7101a]}
{[Bd, hc-HubConnectionAPI.e4cd4be5-cc89-4f5e-973c-ddb9fa43ee4d]}
{[B:, c-06fc7efd-8316-41a7-a204-412124cf43ce]}
{[BI, hc-HubConnectionAPI.1a67fbdf-1b15-4999-9701-bdd4235e8e55]}
{[Bo, ack-add4daa3-ac01-4b72-b218-2333feb7a9d7]}
{[B5, c-67e04c36-49ce-4ec5-b0b8-020d814353d4]}
{[BZ, ack-5cdb277a-2ffc-40f3-b020-79b80d417bb8]}
{[Bx, ack-a8091b49-b934-45ef-bd1d-b0ae32505cde]}
{[BU, hc-HubConnectionAPI.4a341189-44f9-4239-bf41-0565af9ad078]}
{[Bk, c-e7ee57ba-78ff-4310-8a36-99ea3459abd7]}
{[B1, hc-HubConnectionAPI.f82aee8f-e54e-4895-a3db-d2637c0af8b0]}
{[CD, ack-1a3cfe64-cdab-4eee-af9c-d76230c6f3f0]}
{[BD, c-0afd0453-d3fa-42a4-8dd2-94678cb18004]}
{[B8, c-d5bd3e8e-ef9e-4551-8512-fd0491adfe88]}
{[BQ, ack-349e1ecd-9bd6-4e4a-8281-009f5adeca6e]}
{[Bw, c-a8091b49-b934-45ef-bd1d-b0ae32505cde]}
{[BX, hc-HubConnectionAPI.5cdb277a-2ffc-40f3-b020-79b80d417bb8]}
David Fowler
Owner

@RichardW1001 let's not turn this one bug into a discussion about several bugs. This issue is about the performance problem you're having with long polling. I have some free cycles to start taking a look at this. If you have another issue with cursors then file another bug.

David Fowler
Owner

The project is failing to load the Metris load test project:

image

I'm not sure if it has something to do with the fact that it was under source control.

David Fowler
Owner

@RichardW1001 turns our this is a client bug. We're not cleaning up state on the connection properly for long polling when you stop and start the same connection. We're going to fix it in 2.0. In the mean time you can workaround this by creating a new connection on start. I've updated the performance harness to show this new logic http://signalrcrazyharness.cloudapp.net/harness.js

N. Taylor Mullen NTaylorMullen was assigned
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Captured all timeout ids within the long polling transport and cleare…
…d them on stop.

- This ensures that a secondary poll cannot occur when a connection is stopped then started while reconnecting.

#2125
1e4ba2e
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Added a test to verify that starting/stopping a connection while reco…
…nnecting does not result in simultaneous polls attempting to connect.

#2125
32e4e9f
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Captured all timeout ids within the long polling transport and cleare…
…d them on stop.

- This ensures that a secondary poll cannot occur when a connection is stopped then started while reconnecting.

#2125
2009f5a
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Added a test to verify that starting/stopping a connection while reco…
…nnecting does not result in simultaneous polls attempting to connect.

#2125
ca1691c
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Addressed code review comments.
- Added an extra check after long polling error handler trigger to ensure that multiple connections do not occur.

#2125
35bcfc0
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Captured all timeout ids within the long polling transport and cleare…
…d them on stop.

- This ensures that a secondary poll cannot occur when a connection is stopped then started while reconnecting.

#2125
a3d7327
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Added a test to verify that starting/stopping a connection while reco…
…nnecting does not result in simultaneous polls attempting to connect.

#2125
b26bd02
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Addressed code review comments.
- Added an extra check after long polling error handler trigger to ensure that multiple connections do not occur.

#2125
e35a3c8
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Captured all timeout ids within the long polling transport and cleare…
…d them on stop.

- This ensures that a secondary poll cannot occur when a connection is stopped then started while reconnecting.

#2125
4841ddb
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Added a test to verify that starting/stopping a connection while reco…
…nnecting does not result in simultaneous polls attempting to connect.

#2125
88c84b9
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Addressed code review comments.
- Added an extra check after long polling error handler trigger to ensure that multiple connections do not occur.

#2125
34ca181
Gustavo Armenta

tested long polling when "/poll" fails it starts doing "/reconnect" until one succeeds and then switch to "/poll". There is no reconnect loop

N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Added a test to verify that starting/stopping a connection while reco…
…nnecting does not result in simultaneous polls attempting to connect.

#2125
2534d99
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Added a test to verify that starting/stopping a connection while reco…
…nnecting does not result in simultaneous polls attempting to connect.

#2125
b6f0c70
N. Taylor Mullen NTaylorMullen referenced this issue from a commit
N. Taylor Mullen NTaylorMullen Added a test to verify that starting/stopping a connection while reco…
…nnecting does not result in simultaneous polls attempting to connect.

#2125
5e5e322
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.