Skip to content

JavaScript Client does not cause OnReconnected event to fire when using longPolling transport #2188

Closed
darcon77 opened this Issue Jun 21, 2013 · 2 comments

5 participants

@darcon77

To reproduce

Client:

    var proxy = $.connection.chatHub;
    proxy.client.logMessage = function (message) {
        console.log(message);
    };

    $.connection.hub.logging = true;
    $.connection.hub.connectionSlow(function () {
        console.log('We are currently experiencing difficulties with the connection.')
    });
    $.connection.hub.error(function (error) {
        console.log('SignalR error: ' + error)
    });
    $.connection.hub.start({ transport: 'longPolling' }).done(function () {
        console.log("Started");
    });

Server:

public class ChatHub : Hub
{

    public override Task OnConnected()
    {
        Clients.Caller.logMessage("Connected");
        return base.OnConnected();
    }

    public override Task OnDisconnected()
    {
        Clients.Caller.logMessage("Disconnected");
        return base.OnDisconnected();
    }

    public override Task OnReconnected()
    {
        Clients.Caller.logMessage("Reconnected");
        return base.OnReconnected();
    }
}

If I don't specify transport, foreverFrame is used. Connection is successfully established and console shows "Connected" message. If I recycle app pool manually or cause the recycle by modifying web.config, console shows "Reconnected" message, indicating that OnReconnected method of the hub was fired.
But if I specify longPolling as my transport, after the initial load console shows "Connected" message. However, when I cause app pool recycle, "Reconnected" message never shows up. Console just keeps logging SignalR: Attempting to connect to 'http://www.myhost.com/signalr/poll?transport=longPolling&connectionToken=FMPkYXaM6FKXM57jmPSCmQQv...&tid=0' using longPolling every 110 seconds.

How should I restore connection to the server? Does the client know when there's no hub listening on the server side so that I can restart connection by $.connection.hub.start()?

@davidfowl
SignalR member

This is an issue we'll look at for a future release.

@halter73 halter73 was assigned Jul 22, 2013
@halter73 halter73 added a commit that referenced this issue Jul 23, 2013
@halter73 halter73 Modify response to indicate to clients that the host is shutting down
- This enables LongPolling to reconnect like other transports during shutdown
- No longer reconnect after connection timeout with the .NET client

#2188
#2323
4f4b70e
@halter73 halter73 added a commit that referenced this issue Jul 25, 2013
@halter73 halter73 Modify response to indicate to clients that the host is shutting down
- This enables LongPolling to reconnect like other transports during shutdown
- No longer reconnect after connection timeout with the .NET client

#2188
#2323
3f83ffd
@halter73 halter73 added a commit that referenced this issue Jul 26, 2013
@halter73 halter73 Modify response to indicate to clients that the host is shutting down
- This enables LongPolling to reconnect like other transports during shutdown
- No longer reconnect after connection timeout with the .NET client

#2188
#2323
f51e074
@halter73 halter73 added a commit that referenced this issue Jul 26, 2013
@halter73 halter73 Modify response to indicate to clients that the host is shutting down
- This enables LongPolling to reconnect like other transports during shutdown
- No longer reconnect after connection timeout with the .NET client

#2188
#2323
c42b9f8
@Xiaohongt Xiaohongt was assigned Jul 26, 2013
@Xiaohongt
SignalR member

Verified that JS client and .Net 4.5 /4.0 clients raise reconnect request when App domain restart or app pool recycle, and OnReconnected event on server raise.

@Xiaohongt Xiaohongt closed this Jul 27, 2013
@halter73 halter73 added a commit that referenced this issue Oct 4, 2013
@halter73 halter73 Updated JS client to trigger reconnect event after host shutdown
#2188

Conflicts:
	src/Microsoft.AspNet.SignalR.Client.JS/jquery.signalR.transports.longPolling.js
f50167b
@halter73 halter73 added a commit that referenced this issue Oct 4, 2013
@halter73 halter73 Added test to verify reconnect fires after host shutdown with LP
#2188

Conflicts:
	src/Microsoft.AspNet.SignalR.Hosting.Memory/MemoryHost.cs
	src/Microsoft.AspNet.SignalR.Hosting.Memory/OwinEnvironment.cs
1ace1bb
@halter73 halter73 added a commit that referenced this issue Oct 4, 2013
@halter73 halter73 Change "timedOut" to "shouldReconnect" in .NET client's ProcessResponse
#2188
#2323

Conflicts:
	src/Microsoft.AspNet.SignalR.Client/Transports/ServerSentEventsTransport.cs
	src/Microsoft.AspNet.SignalR.Client/Transports/TransportHelper.cs
f28a9d0
@halter73 halter73 added a commit that referenced this issue Oct 4, 2013
@halter73 halter73 Modify response to indicate to clients that the host is shutting down
- This enables LongPolling to reconnect like other transports during shutdown
- No longer reconnect after connection timeout with the .NET client

#2188
#2323

Conflicts:
	tests/Microsoft.AspNet.SignalR.FunctionalTests/Server/Connections/ConnectionFacts.cs
	tests/Microsoft.AspNet.SignalR.FunctionalTests/Server/Connections/PersistentConnectionFacts.cs
	tests/Microsoft.AspNet.SignalR.Tests.Common/App_Start/Initializer.cs
170d8db
@halter73 halter73 added a commit that referenced this issue Oct 8, 2013
@halter73 halter73 Updated JS client to trigger reconnect event after host shutdown
#2188

Conflicts:
	src/Microsoft.AspNet.SignalR.Client.JS/jquery.signalR.transports.longPolling.js
4da3844
@halter73 halter73 added a commit that referenced this issue Oct 8, 2013
@halter73 halter73 Added test to verify reconnect fires after host shutdown with LP
#2188

Conflicts:
	src/Microsoft.AspNet.SignalR.Hosting.Memory/MemoryHost.cs
	src/Microsoft.AspNet.SignalR.Hosting.Memory/OwinEnvironment.cs
f47452d
@halter73 halter73 added a commit that referenced this issue Oct 8, 2013
@halter73 halter73 Change "timedOut" to "shouldReconnect" in .NET client's ProcessResponse
#2188
#2323

Conflicts:
	src/Microsoft.AspNet.SignalR.Client/Transports/ServerSentEventsTransport.cs
	src/Microsoft.AspNet.SignalR.Client/Transports/TransportHelper.cs
927e938
@halter73 halter73 added a commit that referenced this issue Oct 8, 2013
@halter73 halter73 Modify response to indicate to clients that the host is shutting down
- This enables LongPolling to reconnect like other transports during shutdown
- No longer reconnect after connection timeout with the .NET client

#2188
#2323

Conflicts:
	tests/Microsoft.AspNet.SignalR.FunctionalTests/Server/Connections/ConnectionFacts.cs
	tests/Microsoft.AspNet.SignalR.FunctionalTests/Server/Connections/PersistentConnectionFacts.cs
	tests/Microsoft.AspNet.SignalR.Tests.Common/App_Start/Initializer.cs
78b0d16
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.