codeproject / CodeProject.AI-Server

CodeProject.AI Server is a self contained service that software developers can include in, and distribute with, their applications in order to augment their apps with the power of AI.
Other
605 stars 141 forks source link

Unable to use docker container attached to macvlan network #3

Closed i286 closed 1 year ago

i286 commented 2 years ago

Here is my compose file (using Portainer with existing macvlan network)

version: "3.9"

services:
  senseai:
    container_name: codeproject_ai
    image: codeproject/ai-server:latest
    environment:
      - TZ=Australia/Melbourne
    networks:
      dmz:
        ipv4_address: 192.168.67.112
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - codeproject-data:/usr/share/CodeProject/AI
    restart: unless-stopped

networks:
  dmz:
    external:
      name: vlan67_dmz

volumes:
  codeproject-data:

When I run this on my server it starts but checking the logs, it errors out, please note there is nothing else on the port of course:

warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Overriding address(es) 'http://+:5000'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instead.
fail: Microsoft.Extensions.Hosting.Internal.Host[9]
      BackgroundService failed
      System.Threading.Tasks.TaskCanceledException: A task was canceled.
         at CodeProject.AI.API.Server.Frontend.VersionProcessRunner.ExecuteAsync(CancellationToken stoppingToken)
         at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
crit: Microsoft.Extensions.Hosting.Internal.Host[10]
      The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted.
      System.Threading.Tasks.TaskCanceledException: A task was canceled.
         at CodeProject.AI.API.Server.Frontend.VersionProcessRunner.ExecuteAsync(CancellationToken stoppingToken)
         at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...
fail: Microsoft.Extensions.Hosting.Internal.Host[9]
      BackgroundService failed
      System.Threading.Tasks.TaskCanceledException: A task was canceled.
         at CodeProject.AI.API.Server.Frontend.BackendProcessRunner.ExecuteAsync(CancellationToken stoppingToken)
         at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
crit: Microsoft.Extensions.Hosting.Internal.Host[10]
      The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted.
      System.Threading.Tasks.TaskCanceledException: A task was canceled.
         at CodeProject.AI.API.Server.Frontend.BackendProcessRunner.ExecuteAsync(CancellationToken stoppingToken)
         at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)

Unable to start the server: Address family not supported by protocol.
Check that another instance is not running on the same port.
Press Enter to close.
ChrisMaunder commented 1 year ago

Is this still an issue with the latest build? That particular setup you're running is outside the scope of what we support so we don't have a test rig setup for it, but if the issue has been solved by by other related issues we've resolved it would be good to know

i286 commented 1 year ago

Just tried again with the latest image available as of right now and it is still same issue :(

The messages are slighty different but same error message as below

Press Enter to close.      gInfor Server: ** Operating System: Linux 5.4.0-124-generic #140-Ubuntu SMP Thu Aug 4 02:23:37 UTC 2022
Infor Server: ** Architecture:     X64
Infor Server: ** Environment:
Infor Server: ** Platform:         docker
Infor Server: ** In Docker:        True
Infor Server: ** App DataDir:      /usr/share/CodeProject/AI
Infor Server: 
Debug Server: ------------------------------------------------------------------
Debug Server: Expanded ROOT_PATH       = /app
Debug Server: Expanded MODULES_PATH    = /app/AnalysisLayer
Debug Server: Expanded PYTHON_BASEPATH = /app/AnalysisLayer/bin/%PYTHON_RUNTIME%/venv
Debug Server: Expanded PYTHON_PATH     = %PYTHON_RUNTIME%
Debug Server: ------------------------------------------------------------------
Infor Server: BackendProcessRunner Start
Trace Server: Starting Background AI Modules
Error Server: BackgroundService failed
Error Server: BackgroundService failed

Unable to start the server: Address family not supported by protocol.
Check that another instance is not running on the same port.
ChrisMaunder commented 1 year ago

Are you trying to access via http:// or https://? We only support http:// at the moment.

vajonam commented 1 year ago

The issue is that the internal server is looking to bind to the IPV6 which is disabled. There needs to be an option to bind only ipv4 addreses

vajonam commented 1 year ago

@ChrisMaunder if you can provide a environment or startup variable to disable binding to IPv6 on startup this should address the problem. I dont know enought about .NET to prevent it from binding to an IPv6 address

vajonam commented 1 year ago

34 same issue

jaromrax commented 1 year ago

No way to start the docker under ubuntu 22/04


Trace ModuleRunner Start
Warni Overriding address(es) 'http://+:32168, http://+:5000'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instea
Trace Starting Background AI Modules
Error BackgroundService failed
Error BackgroundService failed

Unable to start the server: Address family not supported by protocol.
jdrozdnovak commented 1 year ago

While solving this, could you point us to your dockerfiles, I am confident the community can solve this.

i286 commented 1 year ago

I figured it out. I disable ipv6 as a matter of course. I updated another docker app i use and was checking why it wasnt starting up. it suddenly gave me errrors about dual stack not enabled and a very similar message from python as per my original issue. Took me this long to put 2 and 2 together. I tested it by enabling ipv6 on this host and voila...

I can start the codeproject ai server stack with my original config!

EDIT: I must have missed the replies, looks like someone else figured it out above and I was too excited to read all the messages. Anyways would be best to enable dual stack mode as a docker option instead of by default, causing this issue.

ChrisMaunder commented 1 year ago

We will add an option to select IP4 and/or IP6