2013-07-01 164 views
1

我有一個.NET客戶端調用方法在輪轂上,如下所示:SignalR System.InvalidOperationException:緩衝區長度超過

var competition = hubProxy.Invoke<Competition>("GetCompetition", "Queen's Final 2013").Result; 

調試在Windows 8上,我發現了以下錯誤:

20:23:25.0926734 - null - ChangeState(Disconnected, Connecting) 
20:23:25.3748631 - ... - WS: ws://localhost:59570/signalr/connect?transport=webSockets&connectionToken=-Tp4LiB-1w8TjNuw0ilbeMFjw_B8Vl1c31Oni72nbXazWo6qHBSJCRFJU6YD4wJo9dYZ_mb0vNez2hD8JllF0SUXzkhrN4ejcuO1_gBrFrcsK02xJLBnV_z7d774EFlw0&connectionData=[{"Name":"QueensFinalHub"}] 
20:23:25.3968761 - ... - ChangeState(Connecting, Connected) 
20:23:34.2938036 - ... - WS: OnMessage({}) 
20:23:35.5546436 - ... - OnError(System.InvalidOperationException: Buffer length exceeded 
    at Microsoft.AspNet.SignalR.Infrastructure.ByteBuffer.Append(Byte[] segment) 
    at Microsoft.AspNet.SignalR.WebSockets.WebSocketMessageReader.<ReadMessageAsync>d__0.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.<ProcessWebSocketRequestAsync>d__8.MoveNext()) 
20:23:35.5576456 - ... - WS: OnClose(False) 
20:23:35.5596469 - ... - ChangeState(Connected, Reconnecting) 
20:23:35.5616483 - ... - WS: ws://localhost:59570/signalr/reconnect?transport=webSockets&connectionToken=-Tp4LiB-1w8TjNuw0ilbeMFjw_B8Vl1c31Oni72nbXazWo6qHBSJCRFJU6YD4wJo9dYZ_mb0vNez2hD8JllF0SUXzkhrN4ejcuO1_gBrFrcsK02xJLBnV_z7d774EFlw0&connectionData=[{"Name":"QueensFinalHub"}] 
20:23:35.5766587 - ... - ChangeState(Reconnecting, Connected) 
20:23:44.3054789 - ... - WS: OnMessage({}) 

響應數據非常大,但是當我在Windows 7上進行調試時(我認爲連接使用服務器端事件),我沒有收到此錯誤。

這可能是什麼原因造成的?

回答

2

SignalR對消息大小有明顯的默認限制,因爲它試圖成爲一個實時消息框架,而不是一個Web服務框架。 The default is 64kbWebSocketHandler::MaxIncomingMessageSize,這是一個只讀屬性。

看起來你正在嘗試使用SignalR來處理基本的HTTP GET請求。您是否考慮過僅僅使用AJAX針對ASP.NET WebAPI Web服務進行這種數據交換?

+2

這實際上是一個正在修復的錯誤。要解決它,請將傳輸更改爲服務器發送的事件。 – davidfowl

+0

@dfowler我該怎麼做呢? – Jonesopolis

+0

http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-net-client#transport – davidfowl