.Net 6 SignalR - data transfer rate

132 Views Asked by At

I try so send 1 gigabyte of data from an ASP.NET Core Web API server (.NET 6 runtime) with SignalR to a client.

The application flow is as follows: Client calls controller endpoint to start a long running process. This controller endpoint immediately returns Http 202 and starts a background process. Then the client starts a SignalR connection and waits for callbacks. The server send the data with IHubContext as soon as the calculation is finished. The resulting object is around 1 gigabyte in size.

The problem: with Windows resource monitor, I can see that the SignalR client receives a maximum of 70 kilobytes per second. Transferring the data would take hours.

To verify the problem: if I return the 1 gigabyte data directly via the controller endpoint (synchronous HTTP call without callback), then I get data transfer rates of 300 kilobytes per second. This is still slow, but is due to the company network. But it shows that theoretically a higher data transfer rate would be possible than with SignalR.

I adjusted the buffer size in both the client and the server. However, this does not seem to have any effect on the data transfer rate.

Does anyone have any idea what limits the SignalR data transfer rate and how I can fix it?

Server

  routes.MapHub<ValuationHub>("/ValuationHub", options =>
  {
      options.ApplicationMaxBufferSize = 100000000; //100mb
      options.TransportMaxBufferSize = 100000000; //100mb
  });

Client

var connection = new HubConnectionBuilder()
    .WithAutomaticReconnect()
    .WithUrl(acceptedResult.SignalRCallbackUrl, opts =>
    {
        opts.TransportMaxBufferSize = 100000000;
        opts.ApplicationMaxBufferSize = 100000000;
        opts.UseDefaultCredentials = true;
    })
    .Build();
0

There are 0 best solutions below