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
574 stars 136 forks source link

Unable to start the server: Failed to bind to address http://[::]:5000: address already in use.. #44

Closed ahaverty closed 1 year ago

ahaverty commented 1 year ago

Area of Concern

Describe the bug Code Project Server on windows is failing to start due to another service running on port 5000, despite my appsettings.json being set to 32168.

Expected behavior Code Project Server starts on 32168, and doesn't attempt to use port 5000 at all.

Screenshots

image

Your System (please complete the following information):

Additional context

  1. Attempting to start, via BlueIris settings page with port 32168 set silently fails after the timeout.
  2. Trying the CodeProject.AI.Serve.exe manually also fails, and gives me a better understanding of the error:
  3. Note, this is my first attempt at setting up a CodeProject Server instance. I've not edited any json, but can see the port is supposed to default to 32168.
Killing any Orphan Processes.
No Instance(s) Available.
No Instance(s) Available.
No Instance(s) Available.
No Instance(s) Available.
No Instance(s) Available.
No Instance(s) Available.
Infor ** Operating System: Windows (Microsoft Windows 10.0.19044)
Infor ** CPUs:             1 CPU x 4 cores. 8 logical processors (x64)
Infor ** GPU:              NVIDIA GeForce GTX 1060 6GB (6 GiB) (NVidia)
Infor **                   Driver: 516.94 CUDA: 11.7 Compute: 6.1
Infor ** System RAM:       16 GiB
Infor ** Target:           Windows
Infor ** BuildConfig:      Release
Infor ** Execution Env:    Native
Infor ** Runtime Env:      Production
Infor ** .NET framework:   .NET 7.0.3
Infor ** App DataDir:      C:\ProgramData\CodeProject\AI
Infor System GPU info:
Infor GPU 3D Usage       2%
Infor GPU RAM Usage      5.6 GiB
Infor Video adapter info:
Infor NVIDIA GeForce GTX 1060 6GB:
Infor Adapter RAM        4 GiB
Infor Driver Version     31.0.15.1694
Infor Video Processor    NVIDIA GeForce GTX 1060 6GB
Infor Microsoft Remote Display Adapter:
Infor Adapter RAM        0
Infor Driver Version     10.0.19041.2075
Infor Video Processor
Debug ------------------------------------------------------------------
Debug ROOT_PATH               = C:\Program Files\CodeProject\AI
Debug MODULES_PATH            = C:\Program Files\CodeProject\AI\AnalysisLayer
Debug DOWNLOADED_MODULES_PATH = C:\Program Files\CodeProject\AI\modules
Debug PYTHON_BASEPATH         = C:\Program Files\CodeProject\AI\AnalysisLayer\bin\windows\%PYTHON_RUNTIME%\venv
Debug PYTHON_PATH             = C:\Program Files\CodeProject\AI\AnalysisLayer\bin\windows\%PYTHON_RUNTIME%\venv\scripts\Python
Debug Temp Dir:                C:\Users\alan\AppData\Local\Temp\
Debug Data Dir:                C:\ProgramData\CodeProject\AI
Debug ------------------------------------------------------------------
Infor ModuleRunner Start
Trace Starting Background AI Modules

Unable to start the server: Failed to bind to address http://[::]:5000: address already in use..
Check that another instance is not running on the same port.
Press Enter to close.Error BackgroundService failed
Error BackgroundService failed
ahaverty commented 1 year ago

Perhaps the server is hardcoded to attempt something on port 5000 for non MacOS machines? https://github.com/codeproject/CodeProject.AI-Server/blob/65acf54edb29ddd22e3c2df7656739870ea43bea/src/API/Server/FrontEnd/Program.cs#L396

Removing the known service I have on port 5000 would be a mess for me right now unfortunately.

ahaverty commented 1 year ago

I've solved for now by moving the service I had running on 5000 to a different port. CodeProject now starts as expected, with no changes to the default config. I'd say it's an open issue though if I'm right, or at least some help if anyone else hits this.

ChrisMaunder commented 1 year ago

We'll add proper error handling around that piece of code to correct this in our next (2.1) release