繁体   English   中英

如何在Service Fabric ASP.NET Core 2中使用WebListenerCommunicationListener

[英]How to use WebListenerCommunicationListener in Service Fabric ASP.NET Core 2

我刚刚创建了我的第一个ASP.NET Core 2 Stateless Service Fabric Reliable服务,但是我注意到的第一件事是,现在,默认情况下,使用的是在核心1.X中使用的KestrelCommunicationListenerWebListenerCommunicationListener 似乎它已从服务结构aspnetcore库中删除。

这不会让我在同一台物理或虚拟机上配置多个进程以在同一端口上托管Web应用程序,这被唯一的URL路径或主机名所消除。 这些功能在Service Fabric中用于在同一群集中托管多个网站很有用。

有人知道我是否缺少某些东西吗?

谢谢

根据SDK 2.7.198的发行说明,asp.net Core 2.0尚不支持Weblistener。

https://blogs.msdn.microsoft.com/azureservicefabric/2017/08/09/release-of-sdk-2-7-198-and-runtime-5-7-198-for-windows/

项目经理提供的答案

“在ASP.NET Core 2.0中,Microsoft.AspNetCore.Server.WebListener软件包已与Microsoft.Net.Http.Server合并到一个名为Microsoft.AspNetCore.Server.HttpSys的新软件包(aspnet / Announcements#211)中。还没有集成包,因此,如果您使用的是WebListener,则暂时需要保持版本1.xx,对新Microsoft.AspNetCore.Server.HttpSys包的支持将在下一个SDK中提供。功能发布(Azure / service-fabric-aspnetcore#15)。”

根据2017年9月25日发布的SDK版本2.8.0的发行说明, 网址https://msdnshared.blob.core.windows.net/media/2017/10/Microsoft-Azure-Service-Fabric-Release-Notes-SDK -2.8.0-Runtime-6.0.0.pdf ,现在可以使用。

根据发行说明:

在ASP.NET Core 2.0中,WebListener服务器被重新打包并重命名为HttpSys。 现在可以使用HttpSys服务器的Service Fabric集成包:Microsoft.ServiceFabric.AspNetCore.HttpSys。 此程序包包含HttpSys的重命名ICommunicationListener实现:HttpSysCommunicationListener。

如果您当前正在使用WebListener并想升级到ASP.NET Core 2.0,请使用Microsoft.ServiceFabric.AspNetCore.HttpSys程序包而不是Microsoft.ServiceFabric.AspNetCore.WebListener程序包。

 protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners() { return new ServiceInstanceListener[] { new ServiceInstanceListener(serviceContext => new HttpSysCommunicationListener(serviceContext, "ServiceEndpoint", (url, listener) => new WebHostBuilder() .UseHttpSys() .ConfigureService( service => services .AddSingleton<StatelessServiceContext>(serviceContext)) .UseContentRoot(Directory.GetCurrentDirectory()) .UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None) .UseStartup<Startup>() .UseUrls(url) .Build())) }; } 

根据更新的文档,请参阅Service Fabric可靠服务中的ASP.NET Core。

HttpSys基于Windows HTTP Server API构建。 这使用IIS使用的http.sys内核驱动程序来处理HTTP请求,并将它们路由到运行Web应用程序的进程。 这允许同一物理或虚拟机上的多个进程将Web应用程序托管在同一端口上,这由唯一的URL路径或主机名消除了歧义。 这些功能在Service Fabric中用于在同一群集中托管多个网站很有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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