2017-01-16 136 views
2

這是我的JavaScript代碼試圖攔截事件。非常簡單直接。SignalR不捕獲重新連接客戶端事件

 $.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() { 
      //... 
     }); 

Hub start()正確,沒問題。但是,當連接丟失時,中斷點不會被觸發,這些功能都不會被觸發。我知道signalR正在工作,因爲我從控制檯(Chrome調試器)獲得以下輸出。

[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? 

我做錯了什麼?感謝您的幫助:)

SignalR版本(2.2.1)

回答

相關問題