Fork me on GitHub

NetCore同时开启Http和Rpc监听接口

 1 internal static IHostBuilder CreateHostBuilder(string[] args) =>
 2             Host.CreateDefaultBuilder(args)
 3                 .ConfigureWebHostDefaults(webBuilder =>
 4                 {
 5                     webBuilder.ConfigureKestrel(options =>
 6                     {
 7                         options.ListenAnyIP(8001, listenOptions => listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1);
 8                         options.ListenAnyIP(8002, listenOptions => listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2);
 9                         options.ListenAnyIP(8003, listenOptions => listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http3);
10                     });
11                     webBuilder.UseStartup<Startup>();
12                 })
13                 .UseAutofac()
14                 .UseSerilog();

Http1是http监听接口,Http2是rpc监听接口,http3不知道是什么接口。

posted @ 2021-02-03 10:39  雪山玉龙  阅读(473)  评论(0编辑  收藏  举报