也許你不應該增加超時時間。請看這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
。有一點要記住:設置順序KeepAlive
和DisconnectTimeout
是重要的。如果您在設置KeepAlive
後設置DisconnectTimeout
,則會覆蓋KeepAlive
的值。
你不會增加這個超時。我會搜索你有這個超時的原因。 – Tester