4

The Documentation Of MessagePack for C# states that using LZ4 compression you can achieve compact binary sizes of your payload. in docs you can use:enter code here

var lz4Options = MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4BlockArray);
MessagePackSerializer.Serialize(obj, lz4Options);

So it basically says that upon calling every Serialize() and Deserialize() methods, you should specify compression options exclusively.

But when working with .NET Signalr, you don't directly call these methods. Nuget Package Microsoft.AspNetCore.SignalR.Protocols does that for you. you only have to tell the applications serviceCollection to do so in ConfigureServices() method:

public void ConfigureServices(IServiceCollection services)
{
       services.AddSignalR().AddMessagePackProtocol();
}

So I'm curious how to specify MessagePackSerializationOptions for signalr to use LZ4 compression. I already tried changing default option configuration in applications main method:

MessagePackSerializer.DefaultOptions = MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4BlockArray);

But firstly it isn't recommended and secondly It doesn't seem to work :D

Rezga
  • 390
  • 1
  • 10
  • 1
    MessagePackCompression has 2 mode, Have you tried MessagePackCompression. Lz4Block? Lz4BlockArray is introduced in MesagePack v2, you need to find a computability SignalR version for Lz4 compression – Kuroro Oct 07 '20 at 06:48
  • I'm also curious. I know you can do this, but then I think we need something for decompression on the JavaScript side? At least my app broke: `services.AddSignalR().AddMessagePackProtocol(options => options.SerializerOptions = MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4BlockArray).WithSecurity(MessagePackSecurity.UntrustedData));` – Mark Cilia Vincenti Oct 17 '22 at 07:18

0 Answers0