locked
An exception was thrown from the 'Received' event handler. System.FormatException: Messages over 2GB in size are not supported RRS feed

  • Question

  • User-1141244038 posted

    I have a .Net Core SignalR server and UWP application that successfully pushes a JSON formatted string to an UWP client.

    I have in the same solution, using the same .dll as the UWP application a Xamarin Forms app. It has the SignalR Xamarin Forms Nuget package installed. The UWP and Xamarin app both consume a .Net Standard 2 .dll that handles all of the interaction with the SignalR server. 

    The UWP app works perfectly, but when I make exactly the same call with exactly the same parameters, the SignalR client-side code in the Xamarin App throws an internal exception:

    An exception was thrown from the 'Received' event handler. System.FormatException: Messages over 2GB in size are not supported

    There are 15 fields in the JSON structure and it is all values like integer, bool and double. There are also a couple of short strings that are no longer than a dozen or so characters each. The size of the entire JSON structure is will under 1K.

    A possible cause might be the fact that I am using some nullable types like int?, and bool?

    I can supply the full error stack if it helps. I didn't include it in this message because of its size.

    Does anyone have any ideas?

    Saturday, December 16, 2017 9:45 PM

All replies

  • User61956409 posted

    Hi mjl001,<o:p></o:p>

    According to your description, I can know that you have a SignalR Hub server and different Client apps that connect to your Hub server, and Hub server can push JSON structure data/message to UWP client, pushing functionality is not working as expected in your Xamarin app. <o:p></o:p>

    <o:p>

    Messages over 2GB in size are not supported
    </o:p>

    To troubleshoot the issue, you can try to debug and trace the message that you need to pushed to the clients and check the real size of the message/data in your hub method. Besides, please try to push plain text testing message to your Xamarin clients, such as “hello”, and check if clients can receive the message without error.<o:p></o:p>

    With Regards, <o:p></o:p>

    Fei Han<o:p></o:p>

    Monday, December 18, 2017 5:19 AM
  • User-1141244038 posted

    Hi Fei,

    Thank you for your response.

    I should also point out that I am using ASP.Net Core 2.x and the Alpha of SignalR for .Net Core 2.x.

    I have examined the message by writing it to file prior to pushing it to client applications and the size is less than 1K. Exactly the same message is being pushed from the same server side code to both UWP and Xamarin clients. I am using exactly the same code on the receiving end as well as both. All SignalR interaction on the client side is managed inside of theat .Net Standard Core.dll. Both the Xamarin and UWP apps reference that .dll. The only difference is that the consumers of that .dll are different; one is UWP and the other is Android.

    The Xamarin Forms app required the installation of the Xamarin version of SignalR so that it could reference the Core.dll that contains that contains the code that actually processes the SignalR code. Could this be the source of the problems and should I not even attempt to reuse the same .Net Standard SignalR enabled .dll across a UWP and Xamarin project?

    I have yet to try sending a "Hello World" simple text message to the Xamarin app. I have tested that on the UWP app. It was the very first thing I attempted to get working with SignalR in that app and it works fine. I will give that a try sometime in the next few days.

    Michael

    Tuesday, December 19, 2017 6:34 PM
  • User-1141244038 posted

    Hi Fei,

    I just tested the messaging with a simple string that is sent in the OnConnected event on the server side and the same exception is thrown indication that a message may not exceed 2GB.

    On the server side:

    public override async Task OnConnectedAsync()

    {

    await Clients.Client(Context.ConnectionId).InvokeAsync("UpdateConnectionStatus", "Connected");

    }

    On the client side: 

    HubConnection.On<string>("UpdateConnectionStatus", data =>

    {

       Debug.WriteLine($"Received: {data}");

       MessagingCenter.Send<HubClient, string>(this, MessageTypes.UI_UpdateSignalRStatus.ToString(), data);

    });

    A breakpoint on the Debug.Wirteline.... line of code is never hit in the Xamarin app, but it is hit in the Xamarin app.

    Here are the first dozen or so lines from the of the exception that is thrown

    12/19/2017 14:14:03: Connection Id b9d3f51c-ebad-4bcc-88e5-e3a049609550: An exception was thrown from the 'Received' event handler.

    System.FormatException: Messages over 2GB in size are not supported

      at Microsoft.AspNetCore.SignalR.Internal.Formatters.BinaryMessageParser.TryParseMessage (System.ReadOnlyBuffer`1[System.Byte]& buffer, System.ReadOnlyBuffer`1[System.Byte]& payload) [0x00034] in <ebc20eebf7604e23a92256d8ba9f5464>:0 

      at Microsoft.AspNetCore.SignalR.Internal.Protocol.MessagePackHubProtocol.TryParseMessages (System.ReadOnlyBuffer`1[T] input, Microsoft.AspNetCore.SignalR.Internal.IInvocationBinder binder, System.Collections.Generic.IList`1[Microsoft.AspNetCore.SignalR.Internal.Protocol.HubMessage]& messages) [0x00007] in <ebc20eebf7604e23a92256d8ba9f5464>:0 

      at Microsoft.AspNetCore.SignalR.Internal.HubProtocolReaderWriter.ReadMessages (System.Byte[] input, Microsoft.AspNetCore.SignalR.Internal.IInvocatio12-19 14:14:03.445 I/mono-stdout(13623): [41m[30mfail[39m[22m[49m: Microsoft.AspNetCore.Sockets.Client.HttpConnection[19]

    nBinder binder, System.Collections.Generic.IList`1[Microsoft.AspNetCore.SignalR.Internal.Protocol.HubMessage]& messages) [0x00019] in <ebc20eebf7604e23a92256d8ba9f5464>:0 

      at Microsoft.AspNetCore.SignalR.Client.HubConnection+<OnDataReceivedAsync>d__31.MoveNext () [0x00011] in <a8c19fbc9a304fd7975d8b65eaa84f32>:0 

    --- End of stack trace from previous location where exception was thrown ---

      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 

      at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 

      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 

      at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 

      at System.Runtime.CompilerServic12-19 14:14:03.446 I/mono-stdout(13623):       12/19/2017 14:14:03: Connection Id b9d3f51c-ebad-4bcc-88e5-e3a049609550: An exception was thrown from the 'Received' event handler.

     es.TaskAwaiter.GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 

      at Microsoft.AspNetCore.Sockets.Client.HttpConnection+<>c__DisplayClass49_0+<<ReceiveAsync>b__0>d.MoveNext () [0x00099] in <cea2d398efda4b90925321368c204765>:0 12-19 14:14:03.446 I/mono-stdout(13623): System.FormatException: Messages over 2GB in size are not supported

    Tuesday, December 19, 2017 7:26 PM
  • User61956409 posted

    Hi mjl001,<o:p></o:p>

    Your SignalR Hub server can push messages to different Client apps successfully, except Xamarin App. You can try to get help in Xamarin related forums. <o:p></o:p>

    With Regards, <o:p></o:p>

    Fei Han<o:p></o:p>

    Thursday, December 21, 2017 2:15 AM
  • User-1141244038 posted

    Hi Fei,

    Thanks. I will try there.

    Michael

    Thursday, December 21, 2017 11:28 PM