2017-02-09 76 views
0

任務取消等待Groups.Add(groupId,Context.ConnectionId);在Win8上仍然存在WebSockets。 如果此請求超過30秒,我如何增加信號超時。任務取消等待Groups.Add(groupId,Context.ConnectionId);

任務是canceled.mscorlibStackTrace:--- 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任務task) 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任務task)

請幫助我出去了。

+1

你不會增加這個超時。我會搜索你有這個超時的原因。 – Tester

回答

0

也許你不應該增加超時時間。請看這question,因爲它解釋了你可以觀察到的行爲。適當的行動是檢查客戶端提到的問題並相應處理,而不會增加超時時間。

但正如你所問,這裏是你如何做到這一點。將其添加到啓動類中。

// Make long polling connections wait a maximum of 110 seconds for a 
// response. When that time expires, trigger a timeout command and 
// make the client reconnect. 
GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(110); 

// Wait a maximum of 30 seconds after a transport connection is lost 
// before raising the Disconnected event to terminate the SignalR connection. 
GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(30); 

// For transports other than long polling, send a keepalive packet every 
// 10 seconds. 
// This value must be no more than 1/3 of the DisconnectTimeout value. 
GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(10); 

您需要增加DisconnectTimeout。有一點要記住:設置順序KeepAliveDisconnectTimeout是重要的。如果您在設置KeepAlive後設置DisconnectTimeout,則會覆蓋KeepAlive的值。

+0

在我的情況下,我只有一箇中心,我握手並進行組呼。 有沒有什麼辦法可以讓SR向我們提供服務器端連接客戶端的列表,我可以跟蹤客戶端的狀態。 正如我在研發之後發現的,我們必須製作自定義列表,它可以反覆更新SR的連接和斷開事件。 還有同樣的問題如何擺脫這一點。請幫助我。 –

+0

不,沒有辦法獲得連接用戶列表 - 這是真的。您必須重寫集線器的OnConnected和OnDisconnected方法,並自行構建您的已連接用戶列表。 – cassandrad