locked
SignalR Initial start request takes 2-3 seconds before a connection is established with a number of methods in the hub RRS feed

  • Question

  • User2021855791 posted

    I am having a few issues with establishing a connection for SingalR when using Knockout.js.

    We have a number of knockout view models created but they only get bound to the knockout bindings when the element on the pages exists.  We then go through this array to then bind the Viewmodel.

                for (var l = 0; l < arguments.length; l++) {
                    var vm = new arguments[l]();
                    var em = componentElements[l];
                    var template = componentTemplate[l];
                    ko.components.register(componentName[l], {
                        template: { require: template },
                        viewModel: { instance: vm }
                    });
                    ko.applyBindings(vm, em);
                    viewModels.push(vm);
                }

    Once all the bindings have been applied we then start the SignalR hub

                connection.start().done(function () {
                    for (var j = 0; j < viewModels.length; j++) {
                        console.info("Starting ViewModel: " + viewModels[j].constructor.name);
                        if (viewModels[j].init != undefined) {
                            setTimeout(viewModels[j].init(), 0);
                            //viewModels[j].init()
                        }
                    }
                });

    The problem we're experiencing at the moment is the hub establishing a connection:

    [14:54:51 GMT+0100 (GMT Daylight Time)] SignalR: serverSentEvents transport connected. Initiating start request.
    [14:54:53 GMT+0100 (GMT Daylight Time)] SignalR: The start request succeeded. Transitioning to the connected state.

    There is always a 2-3 second pause before it then goes on its way.  I have only found this when 5+ viewmodels are being applied.  Here is a list of what I have tried:

    • Checked dependencies on hubs to make sure they are not holding it up
    • Created a test hub with dependencies from another hub
      • Ensured that methods were called from all the dependencies but within the one method
    • Dev machine is Windows 7 so Websockets isn't available to me and the server it will be deployed to is 2008 R2 (which I think doesn't support websockets) but I have tried different variations of the transport to see if I can improve performance in anyway but ultimately concluded that I would leave it down to the SignalR client to deal with
    • Switching using the SignalR proxy to no proxy

    I am at a loss with what I can try next.  Has anyone got any ideas?

    Thanks

    Friday, October 2, 2015 11:23 AM

All replies

  • User2021855791 posted

    I've given up hope getting support on this and dropped SignalR in favour of WebAPI

    Thursday, October 8, 2015 11:00 AM