How do I prevent CoreWCF base address from being overriden by Kestrel?

389 Views Asked by At

I am initializing a CoreWCF service using Kestrel as a host. The code goes as follows:

var builder = WebApplication.CreateBuilder();
builder.Services.AddServiceModelServices();
builder.WebHost.UseNetTcp(System.Net.IPAddress.Parse(address), int.Parse(port));
builder.WebHost.UseUrls(string.Format("net.tcp://{0}:{1}", address, port));
builder.Logging.AddConsole().AddDebug();

service = builder.Build();

service.UseServiceModel(builder =>
{
    builder.AddService<ServiceImpl>();
    builder.AddServiceEndpoint<ServiceImpl, IService>(binding, endpoint);
});

Task startupTask = service.StartAsync();
startupTask.Wait();

The binding is a NetTcpBinding. The address is "127.0.0.1" and the port is "8001". endpoint is "/endpoint". The intention is to have a service that listens at "net.tcp://127.0.0.1:8001/endpoint".

Note: this is supposed to be a quick-and-dirty prototype designed for understanding how WCF services can be migrated to CoreWCF & Kestrel as a host.

During start up, the console output reads:

warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Overriding address(es) 'net.tcp://127.0.0.1:8001'. Binding to > endpoints defined via IConfiguration and/or UseKestrel() instead.
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://127.0.0.1:8001

There is no configuration file in this application, no json, etc. The code presented contains the configuration. Why is the URI I specified via UseUrls being overriden and how do I fix it?

0

There are 0 best solutions below