microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
382 stars 242 forks source link

Unable to create BC21 container using treafik or/and useSSL #2665

Closed hugifreyr closed 2 years ago

hugifreyr commented 2 years ago

Describe the issue Unable to create BC21 container using treafik or/and useSSL. Getting error Message: The prefix 'http://+:7046/BC/client/' is already registered.. This used to work for earlier version of bc21 dev image. Workaround is to skip using traefik and useSSL.

From Event Log The description for Event ID 216 from source MicrosoftDynamicsNavServer$BC cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

Server instance: BC Tenant ID: Environment Name: Environment Type: User: Type: Microsoft.AspNetCore.Server.HttpSys.HttpSysException ErrorCode: 183 NativeErrorCode: 183 Message: The prefix 'http://+:7046/BC/client/' is already registered. StackTrace: at Microsoft.AspNetCore.Server.HttpSys.UrlGroup.RegisterPrefix(String uriPrefix, Int32 contextId) at Microsoft.AspNetCore.Server.HttpSys.UrlPrefixCollection.RegisterAllPrefixes(UrlGroup urlGroup) at Microsoft.AspNetCore.Server.HttpSys.HttpSysListener.Start() at Microsoft.AspNetCore.Server.HttpSys.MessagePump.StartAsync[TContext](IHttpApplication1 application, CancellationToken cancellationToken) at Microsoft.AspNetCore.Hosting.Internal.WebHost.<StartAsync>d__26.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start() at Microsoft.Dynamics.Nav.Service.AspNetCore.AspNetCoreApiHost.Open() at Microsoft.Dynamics.Nav.WindowsServices.NavServerWindowsService.StartOwinServices() at Microsoft.Dynamics.Nav.WindowsServices.NavServerWindowsService.StartAllServices(ServerUserSettings settings) at Microsoft.Dynamics.Nav.WindowsServices.NavServerWindowsService.Start(String commandLineServiceInstanceName) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.ServiceProcess.ServiceBase.Run(ServiceBase[] services) at Microsoft.Dynamics.Nav.WindowsServices.DynamicsNavServer.Main(String[] args) Source: Microsoft.AspNetCore.Server.HttpSys HResult: -2147467259 StackTrace: at Microsoft.AspNetCore.Server.HttpSys.UrlGroup.RegisterPrefix(String uriPrefix, Int32 contextId) at Microsoft.AspNetCore.Server.HttpSys.UrlPrefixCollection.RegisterAllPrefixes(UrlGroup urlGroup) at Microsoft.AspNetCore.Server.HttpSys.HttpSysListener.Start() at Microsoft.AspNetCore.Server.HttpSys.MessagePump.StartAsync[TContext](IHttpApplication1 application, CancellationToken cancellationToken) at Microsoft.AspNetCore.Hosting.Internal.WebHost.d__26.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start() at Microsoft.Dynamics.Nav.Service.AspNetCore.AspNetCoreApiHost.Open() at Microsoft.Dynamics.Nav.WindowsServices.NavServerWindowsService.StartOwinServices() at Microsoft.Dynamics.Nav.WindowsServices.NavServerWindowsService.StartAllServices(ServerUserSettings settings) at Microsoft.Dynamics.Nav.WindowsServices.NavServerWindowsService.Start(String commandLineServiceInstanceName) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.ServiceProcess.ServiceBase.Run(ServiceBase[] services) at Microsoft.Dynamics.Nav.WindowsServices.DynamicsNavServer.Main(String[] args)

Scripts used to create container and cause the issue New-BCContainer -artifactUrl $artifactUrl -accept_eula -accept_outdated -containerName $ContainerName -auth NavUserPassword -useSSL -memoryLimit $memoryLimit -multitenant:($type -ieq "Sandbox") -Credential $Credential -databaseCredential $DBCredential -databaseServer host.containerhelper.internal -databaseName $databaseName -updateHosts -shortcuts None -isolation process -restart unless-stopped -useTraefik -PublicDnsName $PublicDnsName -addFontsFromPath $addFontsFromPath -myScripts @($EncryptionKey)

Full output of scripts BcContainerHelper is version 3.0.12 BcContainerHelper is running as administrator Hyper-V is Disabled UsePsSession is True Host is Microsoft Windows Server 2019 Datacenter - ltsc2019 Docker Client Version is 19.03.12 Docker Server Version is 19.03.12 Removing Session bc21 Removing container bc21 Removing entries from hosts Removing bc21 from container hosts file Removing bc21- from container hosts file Removing Desktop shortcuts Removing C:\ProgramData\BcContainerHelper\Extensions\bc21 Fetching all docker images Fetching all docker volumes Enabling SSL as otherwise all clients will see mixed HTTP / HTTPS request, which will cause problems e.g. on the mobile and modern windows clients Using image mcr.microsoft.com/businesscentral:10.0.17763.3287 PublicDnsName is mydomainhidden Creating Container bc21 Style: sandbox Multitenant: Yes Version: 21.0.45833.0 Platform: 21.0.45803.0 Generic Tag: 1.0.2.11 Container OS Version: 10.0.17763.3287 (ltsc2019) Host OS Version: 10.0.17763.3287 (ltsc2019) Using process isolation Using locale is-IS Adding special CheckHealth.ps1 to enable Traefik support Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable) Additional Parameters: -e webserverinstance=bc21 -e publicdnsname=mydomainhidden -l "traefik.protocol=https" -l "traefik.web.frontend.rule=PathPrefix:/bc21" -l "traefik.web.port=443" -l "traefik.soap.frontend.rule=PathPrefix:/bc21soap;ReplacePathRegex: ^/bc21soap(.) /BC$1" -l "traefik.soap.port=7047" -l "traefik.rest.frontend.rule=PathPrefix:/bc21rest;ReplacePathRegex: ^/bc21rest(.) /BC$1" -l "traefik.rest.port=7048" -l "traefik.dev.frontend.rule=PathPrefix:/bc21dev;ReplacePathRegex: ^/bc21dev(.) /BC$1" -l "traefik.dev.port=7049" -l "traefik.snap.frontend.rule=PathPrefix:/bc21snap;ReplacePathRegex: ^/bc21snap(.*) /BC$1" -l "traefik.snap.port=7083" -l "traefik.dl.frontend.rule=PathPrefixStrip:/bc21dl" -l "traefik.dl.port=8080" -l "traefik.dl.protocol=http" -l "traefik.enable=true" -l "traefik.frontend.entryPoints=https" --env customNavSettings=PublicODataBaseUrl=https://mydomainhidden/bc21rest/odata,PublicSOAPBaseUrl=https://mydomainhidden/bc21soap/ws,PublicWebBaseUrl=https://mudomainhidden/bc21 Files in C:\ProgramData\BcContainerHelper\Extensions\bc21\my:

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

freddydk commented 2 years ago

could you try to include -alwaysPull to pull the latest generic image to see if that makes a difference?

hugifreyr commented 2 years ago

Thank you, that worked !

freddydk commented 2 years ago

I will add to the next containerhelper that if you have an old generic (pre 1.0.2.13) - I will pull - as this is needed for 21.x

freddydk commented 2 years ago

Shipped in 4.0.3

keshavsrivastav commented 8 months ago

I am getting the similar error while enabling the SSL for oData or/and SOAP web services, please suggest the solution for this.

image

freddydk commented 8 months ago

@keshavsrivastav please create a new issue with full script + output, which repros the problem you are having