Problem trying to connect to a Hub SignalR + Angularjs

5

I have a project with WebApi , SignalR and Angularjs where I do some queries and insertions in real time. Everything works fine when I start the file index.html direct when running the application, however if I try to execute the file individually, even with the application hovering I have the following error:

  

hub is undefined

The error starts in this line of my controller:

hub.client.addItem = function(item) {
   $scope.comments.push(item);
   $scope.$apply();
}

And I define the hub at the beginning, this way:

 var hub = $.connection.myHub; 

Hub running (Direct running on VS server):

Hubnotworking(RunningonaPythonserver):

    
asked by anonymous 05.07.2016 / 22:13

1 answer

2

I solved the problem by referencing the hub path before the start.

var hub = $.connection.myHub;
$.connection.hub.url = "http://localhost:5702/signalr";
$.connection.hub.start().done(function() {
  console.log("Conectado");
}).fail(function(error) {
  console.log('Invocation of start failed. Error: ' + error)
})
    
08.07.2016 / 15:32