We have a SignalR client call back method, which gets called as many times as we move away from and come back to it's containing page. For example: page is salesUpdate.html (Angular template), on this page when coming for the first time, the call back would execute once upon it's event. Now when we move away from this page to another page (say purchaseUpdate.html), and come back to this page i.e. salesUpdate.html, this SignalR client call back method would execute twice. It will execute as many times as we move away from the page and come back to it. From server, this method is called from ASP.NET Web API, and Web API is hit only one time, all subsequent execution of call back does not hit Web API. Here is the client call back method:
var con;
var apiMsgProxy;
$(document).ready(function () {
con = $.hubConnection('http://localhost:51123/signalr');
apiMsgProxy = con.createHubProxy('salesHub');
apiMsgProxy.on('SendSaleUpdate', function (uMsg) {
console.log("Call back SendSaleUpdate called - " + uMsg);
});
con.start().done(function () {
console.log("SignalR connection opened - " + con.state);
}).fail(function () {
console.log('Could not Connect SignalR hub!');
});
});
Any pointer towards this will be greatly appreciated.
$(document).ready()
on the HTML page's script block where it opens hub connection and creates hub proxy. This is not in Angular app controller/service. – NamedropperReconnected
(n-1 times) event? Inspect theConnectionId
maybe. – Cranwell