iamnicoj
iamnicoj

Reputation: 497

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

I just created my first ASP.NET Core 2 Stateless Service Fabric Reliable service but the first thing I notice is that now, by default uses the KestrelCommunicationListener insted of the WebListenerCommunicationListener used in core 1.X. It seems it has been removed from the service fabric aspnetcore libraries.

This won't let me configure multiple processes on the same physical or virtual machine to host web applications on the same port, disambiguated by either a unique URL path or hostname. These features are useful in Service Fabric for hosting multiple websites in the same cluster.

Does anybody know if I´m missing something or is there a workaround?

Thanks

Upvotes: 0

Views: 2876

Answers (4)

user9115485
user9115485

Reputation:

According to the updated docs, see ASP.NET Core in Service Fabric Reliable Services

HttpSys is built on the Windows HTTP Server API. This uses the http.sys kernel driver used by IIS to process HTTP requests and route them to processes running web applications. This allows multiple processes on the same physical or virtual machine to host web applications on the same port, disambiguated by either a unique URL path or hostname. These features are useful in Service Fabric for hosting multiple websites in the same cluster.

Upvotes: 1

Whit Waldo
Whit Waldo

Reputation: 5207

According to the release notes for SDK version 2.8.0 from September 25, 2017 at https://msdnshared.blob.core.windows.net/media/2017/10/Microsoft-Azure-Service-Fabric-Release-Notes-SDK-2.8.0-Runtime-6.0.0.pdf, this is now available.

Per the release notes:

In ASP.NET Core 2.0, the WebListener server was repacked and renamed to HttpSys. A Service Fabric integration package for the HttpSys server is now available: Microsoft.ServiceFabric.AspNetCore.HttpSys. This package contains a renamed ICommunicationListener implementation for HttpSys: HttpSysCommunicationListener.

If you are currently using WebListener and want to upgrade to ASP.NET Core 2.0, use the Microsoft.ServiceFabric.AspNetCore.HttpSys package instead of the Microsoft.ServiceFabric.AspNetCore.WebListener package.

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()))
  };
}

Upvotes: 2

iamnicoj
iamnicoj

Reputation: 497

Answer provided by a PM

"in ASP.NET Core 2.0 the Microsoft.AspNetCore.Server.WebListener package has been merged with Microsoft.Net.Http.Server into a new package called Microsoft.AspNetCore.Server.HttpSys (aspnet/Announcements#211). Service Fabric does not yet have an integration package for this, so if you're using WebListener, you will need to remain on version 1.x.x for the time being. Support for the new Microsoft.AspNetCore.Server.HttpSys package will arrive in the next SDK feature release (Azure/service-fabric-aspnetcore#15)."

Upvotes: 2

Per B
Per B

Reputation: 321

According to the release notes of the SDK 2.7.198, Weblistener is not yet supported for asp.net Core 2.0.

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

Upvotes: 2

Related Questions