4
我有一個使用SignalR和MVC運行的簡單聊天客戶端項目,它幾乎與ASP.Net One(我只是試驗 - 客戶端代碼是相同的)完全相同。因爲它們發生,我有線了下面看的東西:SignalR連接錯誤
$.connection.hub.stateChanged(function(state){console.log(state)});
的連接工作正常,但我發現,如果我關閉IIS Express和觀看Chrome的控制檯,我看到:
//As you would expect the state goes from connected to connecting
Object {oldState: 1, newState: 2}
//Then it times out after about 30 secs and throws this awesomeness at the console
WebSocket connection to 'ws://localhost:61623/signalr?transport=webSockets&connectionToken=VDF640emz7PFMToC6vxle_5-7QS5dZMszV4SPbQO7EFEmSSsITnwKsZreqfl4MGq8TXitG2xB5F-2ZdHp-2t3shPzN2hemTY1ZmEWlB8NOn5orUVexaSoARk9XjEO5B00&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&messageId=B%2C7%7CL%2C0%7CM%2C0%7CN%2C0&tid=0' failed: WebSocket is closed before the connection is established. jquery.signalR-1.0.1.js:1117
//Reconnecting to Disconnecting - so why the error above?
Object {oldState: 2, newState: 4}
//Then radio silence if I start IIS again...
2個問題:
如何避免錯誤時,企圖重新連接失敗?
爲什麼SignalR不會繼續嘗試連接到IIS?我的印象是,這是該技術的點...
編輯下:同樣的事情發生在Firefox太
不知道這是否會幫助您解決問題。 https://github.com/SignalR/SignalR/wiki/Configuring-SignalR – 2013-05-09 15:16:41
@TimBJames - 感謝蒂姆,這真的只是做它超時,我不介意它超時如果服務器爆炸並停止響應,我只想優雅地處理客戶端錯誤:-) – Rob 2013-05-14 06:36:55
在[JabbR](https://jabbr.net/#/rooms/signalr)中粘貼此問題的鏈接,因爲可能有人會幫助您。 – 2013-05-14 08:02:06