Javascript 信号器未捕获客户端上的重新连接事件

Javascript 信号器未捕获客户端上的重新连接事件,javascript,signalr,Javascript,Signalr,下面是我试图截获事件的javascript代码。非常简单和直接 $.connection.hub.reconnecting = function (cb) { $('#hub-info').text(getDateTime() + ': reconnecting... '); //breakpoint if(cb) cb(); }; $.connection.hub.reconnected = fun

下面是我试图截获事件的javascript代码。非常简单和直接

        $.connection.hub.reconnecting = function (cb) {
            $('#hub-info').text(getDateTime() + ': reconnecting... '); //breakpoint
            if(cb) cb();
        };
        $.connection.hub.reconnected = function (cb) {
            $('#hub-info').text(getDateTime() + ': reconnected '); //breakpoint
            if(cb) cb();
        };
        $.connection.hub.disconnected = function (cb) {
            $('#hub-info').text(getDateTime() + ': disconnected '); //breakpoint
            if(cb) cb();
        };
        $.connection.hub.start()
        .done(function () {
            //...
         });
轮毂
start()
正确,没有问题。但是,当连接丢失时,不会命中断点,也不会触发这些函数。我知道signalR正在工作,因为我从控制台(Chrome调试器)获得以下输出

我做错了什么?谢谢你的帮助:)


SignalR版本(2.2.1)

看起来您可能需要将事件用作函数,传入回调,而不是执行赋值

[19:21:02] SignalR: Keep alive has been missed, connection may be dead/slow. jquery.signalR.js:84 
[19:21:08] SignalR: Keep alive timed out.  Notifying transport that connection has been lost. jquery.signalR.js:84 
[19:21:10] SignalR: Closing the Websocket. jquery.signalR.js:84 
[19:21:10] SignalR: webSockets reconnecting. query.signalR.js:84 
[19:21:10] SignalR: Connecting to websocket endpoint 'ws://localhost/sr/reconnect?
$.connection.hub.reconnecting(function () {
  $('#hub-info').text(getDateTime() + ': reconnecting... ');
});