This is the 22nd day of my participation in the August Wen Challenge.More challenges in August

  • 📢 welcome to like: 👍 collect ⭐ message 📝 if there are mistakes please correct, give people rose, hand left lingering fragrance!
  • 📢 This article was originally written by Webmote and originally published by Nuggets.
  • 📢 author’s motto: life is toss about, when you don’t toss about life, life will start to toss about you, let us come on together! 💪 💪 💪

Preface 🎏

The Http3 protocol is built on top of UDP, and yes, it’s amazing that UDP, formerly known as the god of instability, now takes over as the underlying protocol for reliable communications. To eliminate the uncertainty of UDP, QUIC protocol is added on top of UDP.

Using QUIC instead of TCP protocol about reliable, flow control part, so that HTTP3 can be reliable communication transmission.

In the.net 6 preview release of asp.net core, Microsoft added support for HTTP/3, which brings many improvements to the Web. HTTP3 brings faster connection setup and improved performance over low quality networks.

It also shows the high hopes Microsoft has for.NET 6.

Microsoft has now added support for HTTP/3 and for configuring TLS (HTTPS) for HTTP/3.

🎏 1. Configure HTTP/3 TLS

Let’s see how to configure HTTP/3 in a small MVC application using the following command:

dotnet new mvc -o Http3Tls -n Http3Tls
cd Http3Tls
code .
Copy the code

This command creates an MVC application, switches to the project folder and opens VSCode.

We need to configure HTTP/3 in program.cs, as shown in the following code:


public class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder
                    .ConfigureKestrel((context, options) =>
                    {
                        options.EnableAltSvc = true;
                        options.Listen(IPAddress.Any, 5001, listenOptions =>
                        {
							// Enables HTTP/3
                            listenOptions.Protocols = HttpProtocols.Http3;
                            // Adds a TLS certificate to the endpoint
                            listenOptions.UseHttps(httpsOptions =>
                            {
                                httpsOptions.ServerCertificate = LoadCertificate();
                            });
                        });
                    })
                    .UseStartup<Startup>();
            });
}
Copy the code

This indicates that EnableAltSvc sets an Alt-SVC header for the browser.

To indicate that this is an alternative service to existing HTTP/1 or HTTP/2. This requires telling the browser that the alternative service – in this case HTTP/3 – should be treated like the existing service.

This requires an HTTPS connection to be secure and trusted.

Use listenOptions.UseHttps to configure the SSL certificate.

Use listenOptions.Protocols = httpprotocols.http3; Activate the Http3 service.

Yes, as simple as that, an HTTP3-compliant service has been built.

🎏 2 Summary of HTTP /3 advantages

Because Http/3 protocol, based on UDP, it avoids the classic problems of TCP, Http/1, Http/ 2, and realizes a secure, efficient and reliable Http communication protocol.

With 0 RTT connection establishment, smooth connection migration, basically eliminating queue head blocking, and enhanced flow control, it achieves better results than HTTP/2 in most scenarios.

So Http /3 is definitely the future of Http.

🎏 3. Summary

Routine summary, rational view!

Knot is what ah, knot is I want you to praise but can not get lonely. 😳 😳 😳

👓 have seen this, but also care about a thumbs-up?

👓 has been liked, but also care about a collection?

👓 are collected, but also care about a comment?