0

I have a signalr application with the message pack protocol enabled. When the client connecting to my hub has message-pack enabled, everything works well, When I call a client (With message pack disabled) method passing as parameter an object containing a list of objects, Message pack fails throwing an exception with message:

can't find matched constructor. type:Newtonsoft.Json.Linq.JProperty

The stacktrace shows this exception was thrown via the Redis back-plane set up with signalr

Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.GetMessageBytes(HubMessage message) at Microsoft.AspNetCore.SignalR.SerializedHubMessage.GetSerializedMessage(IHubProtocol protocol) at Microsoft.AspNetCore.SignalR.Redis.Internal.RedisProtocol.WriteSerializedHubMessage(Stream stream, SerializedHubMessage message) at Microsoft.AspNetCore.SignalR.Redis.Internal.RedisProtocol.WriteInvocation(String methodName, Object[] args, IReadOnlyList1 excludedConnectionIds) at Microsoft.AspNetCore.SignalR.Redis.RedisHubLifetimeManager1.SendGroupExceptAsync(String groupName, String methodName, Object[] args, IReadOnlyList`1 excludedConnectionIds, CancellationToken cancellationToken)

Here is how I added Message pack and Redis with signalr:

        services.AddSignalR((options) =>
        {
            options.MaximumReceiveMessageSize = 5242880;
            options.EnableDetailedErrors = true;
        })
        .AddRedis(Configuration.GetConnectionString("RedisCache"))
        .AddNewtonsoftJsonProtocol()
        .AddMessagePackProtocol();

I have tried adding custom resolvers to message pack but couldn't resolve this Has anyone ever encountered this issue ? or does anyone have a solution ?

Damien Doumer
  • 1,991
  • 1
  • 18
  • 33
  • `When I call a client (With message pack disabled) method passing as parameter an object containing a list of objects` Do you mean that if you push message that contains list of objects from hub server to connected client(s) not enabling MessagePack which cause the issue? Do you try to do a test to push simple message to same client, does it cause same issue? – Fei Han May 28 '20 at 05:16
  • Yeah, that is what I mean. When I send a simple message it is forwarded correctly but with a list of complex objects, it fails – Damien Doumer May 28 '20 at 17:07

0 Answers0