keiffster / program-y

Python 3.x based AIML 2.0 Chatbot interpreter, framework, related programs and knowledge files
https://keiffster.github.io/program-y/
Other
348 stars 138 forks source link

Cannot start REST or Socket server because OSError: [Errno 98] Address already in use #266

Closed anesuc closed 4 years ago

anesuc commented 4 years ago

Hi all,

I have been trying for a while to get the REST or Socket servers going to no avail. I have changed the config.yaml (from the KeiffBot) by adding a port number (8989 for example) and even changed the IP to 127.0.0.1 from 0.0.0.0 but none of that seem to have an effect on the result.

I am on Ubuntu Linux if that helps.

Expected Behavior

The server should start.

Current Behavior

It keeps using http://0.0.0.0:80 which is as menioned not available. Here is the output from the attempt to start the server

Initiating Sanic REST Service...
Loading, please wait...
No bot root argument set, defaulting to [config/xnix]
sanic Client running on http://0.0.0.0:80
Healthcheck now running as part of REST Service...
sanic Client running in http mode, careful now !
[2020-06-26 10:38:10 +1000] [11956] [INFO] Goin' Fast @ http://0.0.0.0:80
[2020-06-26 10:38:10 +1000] [11956] [ERROR] Experienced exception while trying to serve
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sanic/app.py", line 1172, in run
    serve_multiple(server_settings, workers)
  File "/usr/local/lib/python3.6/dist-packages/sanic/server.py", line 915, in serve_multiple
    sock.bind((server_settings["host"], server_settings["port"]))
OSError: [Errno 98] Address already in use
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.6/dist-packages/programy/clients/restful/sanic/client.py", line 103, in <module>
    REST_CLIENT.run(APP)
  File "/usr/local/lib/python3.6/dist-packages/programy/clients/restful/sanic/client.py", line 78, in run
    workers=self.configuration.client_configuration.workers)
  File "/usr/local/lib/python3.6/dist-packages/sanic/app.py", line 1172, in run
    serve_multiple(server_settings, workers)
  File "/usr/local/lib/python3.6/dist-packages/sanic/server.py", line 915, in serve_multiple
    sock.bind((server_settings["host"], server_settings["port"]))
OSError: [Errno 98] Address already in use

Possible Solution

For it to actually check the config file for this? It seems anything I do in there doesn't change anything for the server configs for some reason. In fact I remember changing the prompt but that didn't change anything Edit: Prompts do change when changed now. No idea why it didn't before. But the issue still remains.

Steps to Reproduce

  1. Download the Rosie bot for example with python3 -m programy.admin.tool download rosie-y
  2. Change the config.yaml in config/xnix and add port: 8989 and change the IP to host: 127.0.0.1. (You can even change the CLI prompt to check if these changes are happening and run the CLI version. I initially just assumed this was a small bug).
  3. Start the server with sudo python3 -m programy.clients.restful.sanic.client --config config/xnix/config.yaml --cformat yaml --logging config/xnix/logging.yaml
  4. And thus it will fail to start

Context (Environment)

I am trying to find a way to communicate with the bot from another program and http local server seems to be the best way to do it/

Detailed Description

I think I've detailed it pretty well above.

Possible Implementation

Maybe this is to do with not reading the config file?

anesuc commented 4 years ago

I managed to get it working by installing y-bot!