简体   繁体   中英

Disabling Nagle algorithm in Kestrel Web Server of ASP.Net Core 2.2

KestrelServerOptions.NoDelay is not available in .NET Core 2.2 any more.

Please how can I disable Nagle algorithm in Kestrel Web Server of ASP.Net Core 2.2?

Disabling Nagle's algorithm is now available at ListenOptions.NoDelay

Here is the code snippet for the same

.ConfigureKestrel((context, options) =>
{
    options.Limits.MaxConcurrentConnections = 100;
    options.Listen(IPAddress.Loopback, 5000, (listenOptions =>
    {
        listenOptions.NoDelay = false;
    }));
});

listenOptions.NoDelay = false; Means enable Nagle algorithm. Set to false to enable Nagle's algorithm for all connections. Defaults to true.

I can't post a comment, but wanted to share this as I couldn't find the answer until I went through the commit history for ListenOptions.cs here . For .Net Core 3.0/3.1, "NoDelay" has moved to SocketTransportOptions.

Example:

var builder = new WebHostBuilder().UseKestrel(kestrelServerOptions => {...}).UseSockets(socketTransportOptions => { socketTransportOptions.NoDelay = false; }).Build();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM