Search code examples
c#blazorsignalr

How to determine actual Signal-R message size


I have a component library, one of its functionalyty is to pass large file from JS to c# code. I split the file into chunks, but I need to know what chunk size should be used.

Default message size is 32 kb, but user can change it in theirs app:

services.AddSignalR(o => {
   o.MaximumReceiveMessageSize = long.MaxValue;
});

How can I determine the message size in my library code?


Solution

  • On the Server, Inject IOptions<HubOptions> options into a service or controller.

    var maximumReceiveMessageSize = options.Value.MaximumReceiveMessageSize;