1

我有一个 .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 上调试时(我相信连接使用服务器端事件),我没有收到此错误。

这可能是什么原因造成的?

4

1 回答 1

4

SignalR 对消息大小有合理的默认限制,因为它试图成为实时消息传递框架,而不是 Web 服务框架。默认值为 64kbWebSocketHandler::MaxIncomingMessageSize这是一个只读属性。

您似乎正在尝试将 SignalR 用于应该是基本的 HTTP GET 请求。您是否考虑过仅针对 ASP.NET WebAPI Web 服务使用 AJAX 来进行这种数据交换?

于 2013-07-01T23:57:34.403 回答