我有一个.NET客户端在集线器上调用方法,如下所示:
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上调试时(我相信连接使用服务器端事件),我没有收到此错误。
导致这种情况的原因是什么?
答案 0 :(得分:4)
SignalR对消息大小有明智的默认限制,因为它试图成为实时消息传递框架,而不是Web服务框架。 The default is 64kb WebSocketHandler::MaxIncomingMessageSize
,这是一个只读属性。
您似乎正在尝试将SignalR用于基本的HTTP GET请求。您是否考虑过针对ASP.NET WebAPI Web服务使用AJAX进行此类数据交换?