0

I've scoured the site, coming across SignalR OnConnected and OnDisconnected not firing and similar, but the solution does not apply in my case. I already do have the client methods registered.

Additionally, the OnConnected method of my hub does fire when running on my local box. It simply does not fire when deployed. All other methods work fine, however. For the present, I've created a work-around as such:

<script>
    $(function () {
        var myHub = $.connection.myHub;
        myHub.client.clientMessage = function (message) { alert(message); };

        // Start the connection.
        $.connection.hub.start().done(function () {
            myHub.server.superfluousMethodToDoSameThingInOnConnect();
        });
    });
</script>

I would really like to stop using this second call, however, and simply have OnConnected work properly as it should. What is necessary on my deployment server to have it work the same?

For reference, my SignalR is version 1.2.2 (limited to .NET 4.0, for now) incorporated into an MVC site (with no errors, otherwise). My dev box is Windows 7 hosting in IIS Express 8.5 The deployment box is Winows Server 2003 hosting in IIS V6.0.

Edit 1: I've included a

myHub.connection.stateChanged(function (change) { alert("State: " + change.newState); });

for debugging, and when the page loads, it displays popup of "State: 0" followed by a popup of "State: 1" a short time later, and a "State: 4" when I leave the page, so it looks like my connection itself is behaving correctly. This functions the same both locally and on the deploy server.

Edit 2: To test further, I have updated the methods in the hub as below:

public override Task OnConnected()
{
    Groups.Add(Context.ConnectionId, Context.User.Identity.Name);
    Clients.All.clientMessage("OnConnected:: ID: " + Context.ConnectionId + " USER: " + Context.User.Identity.Name);
    return base.OnConnected();
}

public void SuperfluousMethodToDoSameThingInOnConnect()
{
    Clients.All.clientMessage("SuperfluousMethodToDoSameThingInOnConnect:: ID: " + Context.ConnectionId + " USER: " + Context.User.Identity.Name);
}

Results of this testing show that only the text sent from SuperfluousMethodToDoSameThingInOnConnect is shown back to the Caller. However, other clients (tested in other browser windows) see both the text from OnConnected and SuperfluousMethodToDoSameThingInOnConnect.

Additionally, when I try to send a message back to the caller using Context.Groups(Context.User.Identity.Name) then the message is not sent. However, if I move the group registration line Groups.Add(Context.ConnectionId, Context.User.Identity.Name) from OnConnected into SuperfluousMethodToDoSameThingInOnConnect, then messages can be sent using Groups.Add(Context.ConnectionId, Context.User.Identity.Name). This seems extremely bizarre, as I can see that the OnConnected method is called, but the Group is not really registered?

Really at a loss for anything to explain this erratic behavior.

Edit 3: Pushed the web app out to a Windows Server 2012 VM, where I found it works correctly, same as my local dev box. Is it that SignalR does not fully work on IIS 6?

Community
  • 1
  • 1
Mike Guthrie
  • 4,029
  • 2
  • 25
  • 48

1 Answers1

2

As per 'Supported server IIS versions' in the http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/supported-platforms only IIS7 or newer are supported.

Pawel
  • 31,342
  • 4
  • 73
  • 104
  • Thanks! From that site, I saw that http://www.asp.net/signalr/overview/signalr-1x/getting-started-with-aspnet-signalr/supported-platforms is the more applicable link, as per my SignalR 1.x version, but I also see that page specifies IIS7+ and only integrated, not classic (of which IIS6 is), mode. – Mike Guthrie Sep 09 '14 at 18:23
  • Thanks again! With that info, I've been able to at least comment everything appropriately so that we can go back and clean things up the correct way when we can do a server upgrade. Will just have to live with the workarounds for now. – Mike Guthrie Sep 09 '14 at 18:41