2017-08-15 79 views
0

我剛剛創建了我的第一個ASP.NET Core 2無狀態服務結構可靠服務,但我注意到的第一件事是現在默認情況下使用KestrelCommunicationListener insted的WebListenerCommunicationListener在覈心1.X.它似乎已從服務結構aspnetcore庫中刪除。如何在服務結構ASP.NET Core 2中使用WebListenerCommunicationListener

這不會讓我在相同的物理或虛擬機上配置多個進程,以便在同一個端口上託管Web應用程序,並通過唯一的URL路徑或主機名消除歧義。這些功能在Service Fabric中用於託管同一集羣中的多個網站很有用。

有誰知道我是否錯過了某些東西或是否有解決方法?

感謝

+0

是不是WebListener重命名爲HttpSysListener? https://開頭github上。COM /天青/服務織物aspnetcore /問題/ 15 – Mardoxx

回答

2

回答的Microsoft.AspNetCore.Server.WebListener包已被合併Microsoft.Net.Http.Server到一個所謂的新包裝Microsoft.AspNetCore.Server.HttpSys(aspnet/Announcements#211)。Service Fabric尚未爲此提供集成包,因此如果您使用的是WebListener,則需要暫時​​保留在版本1.xx上。新的Microsoft.AspNetCore.Server.HttpSys軟件包將支持下一個SDK功能版本(Azure/service-fabric-aspnetcore#15)。「

1

根據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 2.0的核心,在WebListener服務器被重新包裝並更名 到HttpSys。用於HttpSys 服務器的Service Fabric集成軟件包現已推出:Microsoft.ServiceFabric.AspNetCore.HttpSys。 該軟件包包含一個用於HttpSys的重命名的ICommunicationListener實現 :HttpSysCommunicationListener。

如果您正在使用WebListener並希望升級到ASP.NET 核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())) 
    }; 
} 
1

按照最新的文檔,請參閱ASP.NET Core in Service Fabric Reliable Services

HttpSys是建立在Windows HTTP服務器API。這使用IIS使用的http.sys內核驅動程序處理HTTP請求並將它們路由到運行Web應用程序的進程。 這允許同一物理或虛擬機上的多個進程在同一個端口上託管Web應用程序,並由唯一的URL路徑或主機名消除歧義。這些功能在Service Fabric中用於託管同一集羣中的多個網站很有用。

相關問題