Action Server Docker-Compose Connection refused

Hello,

I want to start my action server with docker-compose. Therefore I added this to my docker-compose file:

  action_server:
    image: rasa/rasa-sdk:latest
    networks: ['rasa-network']
    ports:
    - "5055:5055"
    volumes:
    - "/app/actions"

The server seems to start properly as I get this output in the console we running docker-compose:

INFO rasa_sdk.endpoint - Action endpoint is up and running on http://0.0.0.0:5055

However, as soon as a custom action is called, the following error arises:

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host localhost:5055 ssl:default [Connection refused]

Can anybody tell me what I am doing wrong here? I saw that several other people posted this error before, but it seems like, there is no solution yet?

Thanks in advance!

Rasa --v:

Rasa Version      :         3.0.4
Minimum Compatible Version: 3.0.0
Rasa SDK Version  :         3.0.2
Rasa X Version    :         None
Python Version    :         3.7.2
Operating System  :         Darwin-20.6.0-x86_64-i386-64bit
Python Path       :         /Users/theresa/.pyenv/versions/3.7.2/bin/python3.7

@threxx can you share all the related files of docker and docker-compose, please?

Yes of course.

A quick explanation I have 2 projects (English, German) in one repo and therefore need to rename/copy certain files. That’s what I am trying to do in the Dockerfile. Additionally, both have an importer project (each for its language) the GreetBot. I am only pasting the files of the English project as the structure is totally the same (just different language):

Dockerfile:


FROM rasa/rasa:3.0.6-full

COPY config_en.yml /app/config.yml

COPY endpoints.yml /app/endpoints.yml

COPY projects/ABC_en/* /app/projects/ABC_en/

COPY projects/GreetBot_en/* /app/projects/GreetBot_en/

COPY projects/ABC_en/actions/* /app/projects/ABC_en/actions/

RUN rasa train -c ./config_en.yml --out /app/models

ENTRYPOINT ["rasa"]

Docker-compose:

version: '3.0'
networks: {rasa-network: {}}
services:
  rasa:
    image: abc_en:1.0
    ports:
      - "5005:5005"
    command:  run -m /app/models/ --enable-api --endpoints /app/endpoints.yml --credentials /app/credentials.yml --cors "*"
    networks: ['rasa-network']

  action_server:
    image: rasa/rasa-sdk:latest
    networks: ['rasa-network']
    ports:
    - "5055:5055"
    volumes:
    - "/app/projects/ABC_en/actions/"

endpoints.yml:

# This file contains the different endpoints your bot can use.

action_endpoint:
  url: "http://action_server:5055/webhook"

Please let me know if I am doing something wrong here, I really tried my best.

So I fixed the initial error. However, there seems to be still a problem with the action server.

I now get the following error when calling a custom action:

 2022-02-02 14:57:33 ERROR    rasa_sdk.endpoint  - No registered action found for name 'action_course_set'.
ABC_en-rasa-1           | 2022-02-02 14:57:33 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_course_set'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.

I think the action.py is not correctly loaded or found. But I do not how to fix it. Any suggestions?

@threxx please check the code of this action action_course_set have you mentioned this in domain.yml or stories.yml or rules.yml because of this action_server not running. Even, If you have some API or etc please check.

I would also recommend running the action.py locally, fixing the issue or checking if it’s running properly or not, and then try running with docker-compose.

Tip: even add user: root in docker-compose.yml

@nik202

thanks for your input. Locally everything works fine and the custom actions are called without any errors.

@threxx ok, sounds interesting. Can you share docker ps, also can you show the docker-compose up and error log in container?

@nik202

So docker ps shows:

CONTAINER ID   IMAGE                  COMMAND                  CREATED              STATUS              PORTS                    NAMES
21098121d0ca   rasa/rasa-sdk:latest   "./entrypoint.sh sta…"   About a minute ago   Up About a minute   0.0.0.0:5055->5055/tcp   ABC_en-action_server-1
e3836779e161   ABC_en:1.0        "rasa run -m /app/mo…"   54 minutes ago       Up About a minute   0.0.0.0:5005->5005/tcp   ABC_en-rasa-1

Docker-compose:

docker-compose -f docker-compose_en.yml -p abc_en up

[+] Running 2/0
 ⠿ Container abc_en-rasa-1           Created                                                                                                                                                              0.0s
 ⠿ Container abc_en-action_server-1  Created                                                                                                                                                              0.0s
Attaching to abc_en-action_server-1, abc_en-rasa-1
abc_en-action_server-1  | 2022-02-02 15:53:21 INFO     rasa_sdk.endpoint  - Starting action endpoint server...
abc_en-action_server-1  | 2022-02-02 15:53:21 INFO     rasa_sdk.endpoint  - Action endpoint is up and running on http://0.0.0.0:5055
abc_en-rasa-1           | 2022-02-02 15:53:24 INFO     root  - Starting Rasa server on http://0.0.0.0:5005
abc_en-rasa-1           | 2022-02-02 15:53:26 INFO     rasa.core.processor  - Loading model /app/models/20220202-145147-little-terrier.tar.gz...

And then the whole error log:

abc_en-rasa-1           | 2022-02-02 15:53:24 INFO     root  - Starting Rasa server on http://0.0.0.0:5005
abc_en-rasa-1           | 2022-02-02 15:53:26 INFO     rasa.core.processor  - Loading model /app/models/20220202-145147-little-terrier.tar.gz...
abc_en-rasa-1           | /opt/venv/lib/python3.8/site-packages/rasa/utils/train_utils.py:527: UserWarning: constrain_similarities is set to `False`. It is recommended to set it to `True` when using cross-entropy loss.
abc_en-rasa-1           |   rasa.shared.utils.io.raise_warning(
abc_en-rasa-1           | 2022-02-02 15:54:16 INFO     root  - Rasa server is up and running.
abc_en-action_server-1  | 2022-02-02 15:56:25 ERROR    rasa_sdk.endpoint  - No registered action found for name 'action_course_set'.
abc_en-rasa-1           | 2022-02-02 15:56:25 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_course_set'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
abc_en-rasa-1           | Traceback (most recent call last):
abc_en-rasa-1           |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 722, in run
abc_en-rasa-1           |     response = await self.action_endpoint.request(
abc_en-rasa-1           |   File "/opt/venv/lib/python3.8/site-packages/rasa/utils/endpoints.py", line 173, in request
abc_en-rasa-1           |     raise ClientResponseError(
abc_en-rasa-1           | rasa.utils.endpoints.ClientResponseError: 404, Not Found, body='b'{"error":"No registered action found for name \'action_course_set\'.","action_name":"action_course_set"}''
abc_en-rasa-1           |
abc_en-rasa-1           | The above exception was the direct cause of the following exception:
abc_en-rasa-1           |
abc_en-rasa-1           | Traceback (most recent call last):
abc_en-rasa-1           |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 868, in _run_action
abc_en-rasa-1           |     events = await action.run(
abc_en-rasa-1           |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 746, in run
abc_en-rasa-1           |     raise RasaException("Failed to execute custom action.") from e
abc_en-rasa-1           | rasa.shared.exceptions.RasaException: Failed to execute custom action.
abc_en-action_server-1  | 2022-02-02 15:56:25 ERROR    rasa_sdk.endpoint  - No registered action found for name 'action_get_courses_buttons'.
abc_en-rasa-1           | 2022-02-02 15:56:25 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_get_courses_buttons'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
abc_en-rasa-1           | Traceback (most recent call last):
abc_en-rasa-1           |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 722, in run
abc_en-rasa-1           |     response = await self.action_endpoint.request(
abc_en-rasa-1           |   File "/opt/venv/lib/python3.8/site-packages/rasa/utils/endpoints.py", line 173, in request
abc_en-rasa-1           |     raise ClientResponseError(
abc_en-rasa-1           | rasa.utils.endpoints.ClientResponseError: 404, Not Found, body='b'{"error":"No registered action found for name \'action_get_courses_buttons\'.","action_name":"action_get_courses_buttons"}''
abc_en-rasa-1           |
abc_en-rasa-1           | The above exception was the direct cause of the following exception:
abc_en-rasa-1           |
abc_en-rasa-1           | Traceback (most recent call last):
abc_en-rasa-1           |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 868, in _run_action
abc_en-rasa-1           |     events = await action.run(
abc_en-rasa-1           |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 746, in run
abc_en-rasa-1           |     raise RasaException("Failed to execute custom action.") from e
abc_en-rasa-1           | rasa.shared.exceptions.RasaException: Failed to execute custom action.

I really think the action file is not loaded / copied correctly.

@threxx can you confirm on thing:

abc_en:1.0 is this your rasa server image? or it should be rasa/rasa:latest ( check docker hub please)

Just curious.

@threxx If you need to get more idea how you can dockerized the rasa open source please ref this detail thread : Dockerizing my rasa chatbot application that has botfront - #11 by nik202

Hope this will help you!

@nik202 Yes, abc_en:1.0 is the image I create with the DOCKERFILE mentioned above (with: docker image build -t abc_en:1.0 . -f Dockerfile). That’s why I add this to the docker-compose file. Is this not correct?

@nik202

So I updated everything according to your blog post, resulting in following files:

Dockerfile (action):

FROM rasa/rasa-sdk:3.0.2
WORKDIR /app
EXPOSE 5055
USER 1001

Dockerfile (rasa):

FROM rasa/rasa:3.0.4-full
WORKDIR  '/app'
COPY . /app
USER root
RUN rasa train
VOLUME /app/models
CMD [ "run","-m","/app/models","--enable-api","--cors","*","--debug" ,"--endpoints", "endpoints.yml", "--log-file", "out.log", "--debug"]
EXPOSE 5005

Docker-compose:

version: '3'
services:
    rasa:
      container_name: "rasa_server"
      user: root
      build: 
        context: ./rasa/projects/abc_en
      volumes:
      - "./:/app"
      ports: 
        - "5005:5005"
    action_server:
      container_name: "action_server"
      build: 
        context: ./rasa/projects/abc_en/actions
      volumes:
        - ./actions:/app/actions
        - ./data:/app/data
      ports:
        - 5055:5055

endpoints.yml

action_endpoint:
  url: "http://action_server:5055/webhook"

Everything builds and starts without errors. However, as soon as I make a request (with postman) to (http://localhost:5005/webhooks/rest/webhook) which uses custom actions I get the following error in the console:

rasa_server    | 2022-02-03 12:13:07 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_get_achievements'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
rasa_server    | Traceback (most recent call last):
rasa_server    |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 868, in _run_action
rasa_server    |     events = await action.run(
rasa_server    |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 709, in run
rasa_server    |     raise RasaException(
rasa_server    | rasa.shared.exceptions.RasaException: Failed to execute custom action 'action_get_achievements' because no endpoint is configured to run this custom action. Please take a look at the docs and set an endpoint configuration via the --endpoints flag. https://rasa.com/docs/rasa/custom-actions

I am not sure what’s wrong here as I added an endpoint and the actions server is running. Any ideas?

@nik202 any idea why the action server endpoint seems not to be configured?

@threxx now fix the code for action_get_achievements, as per error its having issue.

@nik202 the code works, I tested everything locally (without docker) and every action works perfectly fine.

@threxx did you provide any path for that actions? It’s hard for me to comment without seeing the code.

@nik202

okay I this is my project structure:

docker-compose.yml
- rasa
-- projects
--- abc_de
--- abc_en
---- config.yml
---- endpoints.yml
---- Dockerfile
---- domain.yml
---- data
----- nlu.yml
----- stories.yml
---- actions
----- action.py
----- Dockerfile

Now my action Dockerfile looks like this:

FROM rasa/rasa-sdk:3.0.2
WORKDIR '/app'
EXPOSE 5055
USER 1001

my rasa Dockerfile looks like this:

FROM rasa/rasa:3.0.4-full
WORKDIR '/app'
COPY . /app
USER root
RUN rasa train
VOLUME /app/models
CMD [ "run","-m","/app/models","--enable-api","--cors","*","--debug" ,"--endpoints", "endpoints.yml", "--log-file", "out.log", "--debug"]
EXPOSE 5005

and my docker-compose.yml file looks like this:

version: '3'
services:
    rasa:
      container_name: "rasa_server"
      user: root
      build: 
        context: ./rasa/projects/abc_en
      volumes:
      - "./:/app"
      ports: 
        - "5005:5005"
    action_server:
      container_name: "action_server"
      build: 
        context: ./rasa/projects/abc_en/actions
      volumes:
        - ./actions:/app/actions
        - ./data:/app/data
      ports:
        - 5055:5055

endpoints.yml

action_endpoint:
  url: "http://action_server:5055/webhook"

Maybe that helps with finding the error. I think I somehow/somewhere did not put the correct path, but I am not sure where. The stories which do not require custom actions work perfectly fine. Only the custom actions do not work.

@threxx

What are these?

— abc_de

— abc_en

Two different project folders?

If any action looking for the path or (seeking data) you need to provide the correct path as now you have copied everything in the container or try to provide relative path "./"

@nik202 yes abc_de and abc_en are two different projects (same project different language). So everything I am using is in abc_en and the docker-compose.yml is outside of this structure.

No worries! I actually was able to fix a lot of errors by myself (you might have seen my edits) so I had good progress. And I am very happy and so thankful that you are still trying to fix my problem here. I am stuck with that path. I cannot figure out where I have to provide the correct path. Is it inside the docker-compose.yml or in the action Dockerfile?