Search code examples
c#asp.net-corekestrel-http-serverasp.net-core-3.0

Disabling Nagle algorithm in Kestrel Web Server with ASP.NET Core 3.0


ListenOptions.NoDelay is removed and not available in .NET Core 3.0 anymore. In the documentation for migrating to 3.0 (https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio#transport-abstractions-moved-and-made-public) it says:

NoDelay was moved from ListenOptions to the transport options.

But it doesn't show how this change shall be implemented.

How can I set the NoDelay option to false in .NET Core 3.0? Thanks!


Solution

  • Add a package reference to

    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" Version="3.0.0" />
    

    and invoke :

    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder
                .UseLibuv(opts =>{
                    opts.NoDelay = false;
                })
                .UseStartup<Startup>();
        });
    

    See official docs on Transport configuration