Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

"InvalidDataException: Error binding arguments" after switching to MessagePackProtocol from Json #2937

@devna13

Description

@devna13

Hi,

using Json as hubprotocol everything works correctly but switching to MessagePack Protocol causing binding error.

Chrome Console:
Error: Error: Failed to invoke 'SendImageToTeamWall' due to an error on the server. InvalidDataException: Error binding arguments. Make sure that the types of the provided values match the types of the hub method being invoked.

messagepack err

Visual studio output:

App.Web> ===> [09:59:10.323] [Error] Failed to invoke hub method '"SendImageToTeamWall"'.
App.Web> System.IO.InvalidDataException: Error binding arguments. Make sure that the types of the provided values match the types of the hub method being invoked. ---> System.IO.InvalidDataException: Deserializing object of the `String` type for 'argument' failed. ---> System.InvalidOperationException: code is invalid. code:3 format:positive fixint
App.Web>    at MessagePack.Decoders.InvalidString.Read(Byte[] bytes, Int32 offset, Int32& readSize)
App.Web>    at MessagePack.MessagePackSerializer.Deserialize[T](ArraySegment`1 bytes, IFormatterResolver resolver)
App.Web>    at lambda_method(Closure , ArraySegment`1 , IFormatterResolver )
App.Web>    at MessagePack.MessagePackSerializer.NonGeneric.Deserialize(Type type, ArraySegment`1 bytes, IFormatterResolver resolver)
App.Web>    at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.DeserializeObject(Byte[] input, Int32& offset, Type type, String field, IFormatterResolver resolver)
App.Web>    --- End of inner exception stack trace ---
App.Web>    at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.DeserializeObject(Byte[] input, Int32& offset, Type type, String field, IFormatterResolver resolver)
App.Web>    at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.BindArguments(Byte[] input, Int32& offset, IReadOnlyList`1 parameterTypes, IFormatterResolver resolver)
App.Web>    --- End of inner exception stack trace ---
App.Web>    at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.BindArguments(Byte[] input, Int32& offset, IReadOnlyList`1 parameterTypes, IFormatterResolver resolver)
App.Web>    at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.CreateInvocationMessage(Byte[] input, Int32& offset, IInvocationBinder binder, IFormatterResolver resolver)

messagepack err server

server:
public Task SendImageToTeamWall(string wallId, string teamId, string fromUserId, string imageAsBase64)

client:

      this._hubConnection
        .invoke(
          'SendImageToTeamWall',
          this.getGroupName(team.teamWall),
          team.id,
          user.id,
          imageAsBase64
        )
        .catch(err => {
          console.error('ChathubService; SendImageToTeamWall Error:', err);
        });
    });

startup:


     services.AddSignalR(o => { o.EnableDetailedErrors = true; })
                .AddMessagePackProtocol(options =>
                {
                    options.FormatterResolvers = new List<MessagePack.IFormatterResolver>()
                    {
                        MessagePack.Resolvers.StandardResolver.Instance
                    };
                });

https://docs.microsoft.com/en-us/aspnet/core/signalr/messagepackhubprotocol?view=aspnetcore-2.1
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions