Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

in JS client when transport fallback OnConnected event in server could get called 2 times for same connection id #2195

Closed
Xiaohongt opened this Issue · 2 comments

3 participants

@Xiaohongt
Collaborator

Functional impact:
in JS client when transport fallback OnConnected event in server could get called 2 times for same connection id

Repro:
1). in Tests.Common, EchoHub, add OnConnected event:

public override Task OnConnected()
        {
            return Clients.All.echo(Context.ConnectionId + " OnConnected");
        }

2). then add below for JS test:

QUnit.asyncTimeoutTest("when client transport fallback, OnConnected Event in server not get called 2 times for same connection id", testUtilities.defaultTestTimeout * 8, function (end, assert, testName) {
    var connection = testUtilities.createHubConnection(end, assert, testName, undefined, false),
        savedProcessMessages = $.signalR.transports._logic.processMessages;
    var echoHub = connection.createHubProxies().echoHub,
        onConnectedEventCallCount = 0,
        onConnectedEventCallValue1;

    echoHub.client.echo = function (value) {
        if (value.indexOf("OnConnected") >1) {
            onConnectedEventCallCount++

            if (onConnectedEventCallCount === 1) {
                onConnectedEventCallValue1 = value;
            }

            if (onConnectedEventCallCount === 2) {
                if (onConnectedEventCallValue1 == value) {
                    assert.ok(false, "OnConnected Event in server called 2 times for same connection id");
                    end();
                }
            }
        }       
    };

    $.signalR.transports._logic.processMessages = function (_, minData) {
        // Look for initialize message, if we get it, ignore it, transports should time out
        if (connection.transport.name === "webSockets") {
            if (!minData.S) {
                savedProcessMessages.apply(this, arguments);
            }
        }
        else {
            savedProcessMessages.apply(this, arguments);
        }       
    }

    connection.start().done(function () {
        assert.ok(true, "Connection started");        
        end();
    }).fail(function () {
        // All transports fell back because they did not get init message, success!
        assert.comment("Connection failed to start!");
        end();
    });

    // Cleanup
    return function () {
        $.signalR.transports._logic.processMessages = savedProcessMessages;
        connection.stop();
    };
});

3). Run the test on IE10

Expected result:
OnConnected event in server get called 1 time for the connection id

Actual result:
we can see that OnConnected event in server get called 2 times for the same connection id

@halter73 halter73 was assigned
@davidfowl
Owner

@halter73 this is a bug with the websocket transport aggressively removing connections when the websocket is closed.

@halter73 halter73 referenced this issue from a commit
@halter73 halter73 Require the WebSocket Transport make an /abort request to abort
- Avoids timeouts being mistakenly registered as aborts
- Unifies abort logic for all transports

#2195 #1231
dd3463a
@halter73 halter73 referenced this issue from a commit
@halter73 halter73 Require the WebSocket Transport make an /abort request to abort
- Avoids timeouts being mistakenly registered as aborts
- Unifies abort logic for all transports

#2195 #1231
f14880e
@Xiaohongt Xiaohongt was assigned
@Xiaohongt
Collaborator

verified that OnConnected event in server called one time

@Xiaohongt Xiaohongt closed this
@halter73 halter73 referenced this issue from a commit
@halter73 halter73 Require the WebSocket Transport make an /abort request to abort
- Avoids timeouts being mistakenly registered as aborts
- Unifies abort logic for all transports

#2195 #1231

#2500
93d3bb8
@halter73 halter73 referenced this issue from a commit
@halter73 halter73 Require the WebSocket Transport make an /abort request to abort
- Avoids timeouts being mistakenly registered as aborts
- Unifies abort logic for all transports

#2195 #1231

#2500
a3bd526
@halter73 halter73 referenced this issue from a commit
@halter73 halter73 Require the WebSocket Transport make an /abort request to abort
- Avoids timeouts being mistakenly registered as aborts
- Unifies abort logic for all transports

#2195 #1231

#2500
98e0baa
@halter73 halter73 referenced this issue from a commit
@halter73 halter73 Require the WebSocket Transport make an /abort request to abort
- Avoids timeouts being mistakenly registered as aborts
- Unifies abort logic for all transports

#2195 #1231

#2500
718caae
@halter73 halter73 referenced this issue from a commit
@halter73 halter73 Require the WebSocket Transport make an /abort request to abort
- Avoids timeouts being mistakenly registered as aborts
- Unifies abort logic for all transports

#2195 #1231

#2500
28ce07c
@halter73 halter73 referenced this issue from a commit
@halter73 halter73 Require the WebSocket Transport make an /abort request to abort
- Avoids timeouts being mistakenly registered as aborts
- Unifies abort logic for all transports

#2195 #1231

#2500
1568fa6
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.