Question

I am trying to add SignalR into my MVC application. Every required script to initialize SignalR loading well and in correct order like

Loading

but still when i am trying to read the $.connection.hub.start() i am getting this below error

Hub Error

I am not getting what is going wrong here.

$(function () {
        $.connection.hub.start();
    });
    $.connection.hub.error(function (err) {
        console.log("HUB ERROR : " + err);
    });
    notebook.value('projectactivity', $.connection.projectactivity);

One more thing when i did console.log($.connection) into jquery.signalr*.js file i am getting the $.connection object into console.

Was it helpful?

Solution

I think you are missing to reference hub class.

    $(function () {
        var chat = $.connection.YourHubClass;

       $.connection.hub.start().done(function () {
         // initialization logic that has to occur after SignalR startup
       });

        $.connection.hub.error(function (err) {
           console.log("HUB ERROR : " + err);
        });
    });

OTHER TIPS

you may need to init the start function a callback after signalR loaded, especially when the script is loaded dynamically rather than embedded in the document.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top