When i run my code using "rasa shell" my code works fine even custom action also works....but as i run docker-compose up my custom action not working showing this error

2021-08-18 10:08:22 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_weather_api'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
rasa-chatbot-server | Traceback (most recent call last):
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
rasa-chatbot-server |     return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
rasa-chatbot-server |   File "uvloop/loop.pyx", line 1974, in create_connection
rasa-chatbot-server |   File "uvloop/loop.pyx", line 1951, in uvloop.loop.Loop.create_connection
rasa-chatbot-server | ConnectionRefusedError: [Errno 111] Connection refused
rasa-chatbot-server | 
rasa-chatbot-server | The above exception was the direct cause of the following exception:
rasa-chatbot-server | 
rasa-chatbot-server | Traceback (most recent call last):
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 685, in run
rasa-chatbot-server |     response = await self.action_endpoint.request(
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/rasa/utils/endpoints.py", line 146, in request
rasa-chatbot-server |     async with session.request(
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
rasa-chatbot-server |     self._resp = await self._coro
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request
rasa-chatbot-server |     conn = await self._connector.connect(
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect
rasa-chatbot-server |     proto = await self._create_connection(req, traces, timeout)
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection
rasa-chatbot-server |     _, proto = await self._create_direct_connection(req, traces, timeout)
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection
rasa-chatbot-server |     raise last_exc
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
rasa-chatbot-server |     transp, proto = await self._wrap_create_connection(
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection
rasa-chatbot-server |     raise client_error(req.connection_key, exc) from exc
rasa-chatbot-server | aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host localhost:5055 ssl:default [Connection refused]
rasa-chatbot-server | 
rasa-chatbot-server | During handling of the above exception, another exception occurred:
rasa-chatbot-server | 
rasa-chatbot-server | Traceback (most recent call last):
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 772, in _run_action
rasa-chatbot-server |     events = await action.run(
rasa-chatbot-server |   File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 717, in run
rasa-chatbot-server |     raise RasaException("Failed to execute custom action.")
rasa-chatbot-server | rasa.shared.exceptions.RasaException: Failed to execute custom action.

Can you check the action server logs?

By the way, when posting code or command outputs, please use three backticks (```) a line before and a line after the code to properly format it and make it readable:

```
like so
```

thanks @ChrisRahme ! Please see this…

python3 -m rasa_core_sdk.endpoint --actions actions.py

<---------getting this :---------->

<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
2021-08-18 16:05:20 INFO     __main__  - Starting action endpoint server...
2021-08-18 16:05:20 ERROR    rasa_core_sdk.executor  - Failed to register package 'actions.py'.
Traceback (most recent call last):
  File "/home/sagar/.local/lib/python3.8/site-packages/rasa_core_sdk/executor.py", line 150, in register_package
    self._import_submodules(package)
  File "/home/sagar/.local/lib/python3.8/site-packages/rasa_core_sdk/executor.py", line 137, in _import_submodules
    package = importlib.import_module(package)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'actions.py'
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
<frozen importlib._bootstrap>:219: RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject
2021-08-18 16:05:20 INFO     __main__  - Action endpoint is up and running. on ('0.0.0.0', 5055

python3 -m rasa_core.run -d models/dialogue -u models/nlu --endpoints endpoints.yml````

getting this:

/usr/bin/python3: Error while finding module specification for 'rasa_core.run' (ModuleNotFoundError: No module named 'rasa_core')

Hmm this may have to do with Docker-Compose which I’m not familiar with (I use Helm).

Maybe @nik202 can help?

ok…thanks! @ChrisRahme

@Sagar_Indian Hello! Sorry for the late reply, was busy in endless meetings.

Please can you share me docker-compose file or dockerfile?

@Sagar_Indian please share the endpoints.yml file as the ref and current error. I will try my level best for the solution.

1 Like
version: '2'
services:
  rasa-flask:
    image: rasa-chatbot:latest
    build:
      context: .
      dockerfile: Dockerfile
    container_name: rasa-chat-app
    volumes: 
      - .:/rasa_app
    ports:
      - 5000:5000
    command: python app.py
  rasa-server:
    image: rasa/rasa:2.8.0-full
    container_name: rasa-chatbot-server
    volumes: 
      - .:/app
    ports:
      - 5005:5005
    command: run -m models --enable-api --cors "*"

<<-----endpoints.yml-------->

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

# Server where the models are pulled from.
# https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server

#models:
#  url: http://my-server.com/models/default_core@latest
#  wait_time_between_pulls:  10   # [optional](default: 100)

# Server which runs your custom actions.
# https://rasa.com/docs/rasa/custom-actions

# action_endpoint:
#   url: "http://localhost:5055/webhook"

action_endpoint:
  url: "http://rasa-chatbot-server:5055/webhook"

# nlu:
#   url: 'http://rasa_nlu:5000'

# Tracker store which is used to store the conversations.
# By default the conversations are stored in memory.
# https://rasa.com/docs/rasa/tracker-stores

#tracker_store:
#    type: redis
#    url: <host of the redis instance, e.g. localhost>
#    port: <port of your redis instance, usually 6379>
#    db: <number of your database within redis, e.g. 0>
#    password: <password used for authentication>
#    use_ssl: <whether or not the communication is encrypted, default false>

#tracker_store:
#    type: mongod
#    url: <url to your mongo instance, e.g. mongodb://localhost:27017>
#    db: <name of the db within your mongo instance, e.g. rasa>
#    username: <username used for authentication>
#    password: <password used for authentication>

# Event broker which all conversation events should be streamed to.
# https://rasa.com/docs/rasa/event-brokers

#event_broker:
#  url: localhost
#  username: username
#  password: password
#  queue: queue

@Sagar_Indian where is your rasa-sdk? port 5055? and even mention below syntax that is fine, but where is rasa-sdk image in docker file or you just missed?

action_endpoint:
  url: "http://rasa-chatbot-server:5055/webhook"

@Sagar_Indian Sagar, I’d encourage please see this thread Dockerizing my rasa chatbot application that has botfront - #11 by nik202 and update only flask part in docker and try run. If you have any error do let me know please. I’m sure you will solve this issue. Good Luck!

this is my dockerfile. anything missing here?

FROM rasa/rasa-sdk
FROM tensorflow/tensorflow
RUN mkdir -p /rasa_app
WORKDIR /rasa_app
COPY . /rasa_app
RUN python -m pip install -U pip
RUN pip3 install -r requirements.txt
RUN pip3 install --user rasa-nlu
RUN pip3 install --user rasa-core
RUN python -m spacy download en
RUN pip3 install --user rasa
RUN pip3 install --user sanic
USER root
EXPOSE 5055
USER 1001

@Sagar_Indian Hello! Can you confirm why you using TensorFlow, rasa-nlu, rasa-core, rasa and sanic? any specific reason?

no…there is no any specific reason we can remove.

@Sagar_Indian That great if its not mandatory, can you see this thread as reference for your use case Dockerizing my rasa chatbot application that has botfront - #11 by nik202

I hope this will solve your issue or if you have any issue please let me know. Good Luck!

i tried… for me its not working :expressionless:

Why i am getting this error? where exactly i am doing mistake?

Failed to run custom action 'action_weatherapi'. Couldn't connect to the server at 'http://rasa-server:5055/webhook'. Is the server running? Error: Cannot connect to host rasa-server:5055 ssl:default [Temporary failure in name resolution]
2021-09-06 19:51:26 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_weatherapi'.Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.

why i am getting this exception? how to execute custom action in docker-compose

RasaException: Failed to execute custom action
Traceback (most recent call last):
  File "/home/sagar/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 999, in _create_direct_connection
    hosts = await asyncio.shield(host_resolved)
  File "/home/sagar/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 865, in _resolve_host
    addrs = await self._resolver.resolve(host, port, family=self._family)
  File "/home/sagar/.local/lib/python3.8/site-packages/aiohttp/resolver.py", line 31, in resolve
    infos = await self._loop.getaddrinfo(
  File "uvloop/loop.pyx", line 1469, in getaddrinfo
socket.gaierror: [Errno -3] Temporary failure in name resolution

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/sagar/.local/lib/python3.8/site-packages/rasa/core/actions/action.py", line 685, in run
    response = await self.action_endpoint.request(
  File "/home/sagar/.local/lib/python3.8/site-packages/rasa/utils/endpoints.py", line 163, in request
    async with session.request(
  File "/home/sagar/.local/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/home/sagar/.local/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/home/sagar/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/sagar/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/home/sagar/.local/lib/python3.8/site-packages/aiohttp/connector.py", line 1011, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host rasa-server:5055 ssl:default [Temporary failure in name resolution]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sagar/.local/lib/python3.8/site-packages/rasa/core/processor.py", line 772, in _run_action
    events = await action.run(
  File "/home/sagar/.local/lib/python3.8/site-packages/rasa/core/actions/action.py", line 717, in run
    raise RasaException("Failed to execute custom action.")
rasa.shared.exceptions.RasaException: Failed to execute custom action.

@Sagar_Indian strange, did you see my thread solution and adopted the same approach.

@Sagar_Indian Can you share your docker and docker-compose file for me.

docker-compose.yml

version: '3.0'
services:
  rasa-flask:
    image: rasa:latest-full
    build:
      context:  .
      dockerfile: Dockerfile
    container_name: rasa-chat-app
    volumes: 
      - .:/app
    ports:
      - 5000:5000
    command: python3 app.py
  rasa-server:
    image: rasa/rasa
    container_name: rasa-server
    volumes: 
      - .:/app
    ports:
      - 5005:5005
    command: run -m models --enable-api --cors "*"
    

<-----------dockerfile---------->

FROM rasa/rasa-sdk
FROM tensorflow/tensorflow
RUN mkdir -p /rasa_app
WORKDIR /rasa_app
COPY . /rasa_app
RUN python -m pip install -U pip
RUN pip3 install -r requirements.txt
#RUN pip3 install --user rasa-nlu
#RUN pip3 install --user rasa-core
RUN python -m spacy download en
#RUN pip3 install --user rasa
#RUN pip3 install --user sanic
USER root
EXPOSE 5055
USER 1001

<--------endpoints--------->

action_endpoint:
  url: "http://rasa-server:5055/webhook"

app.py

from flask import Flask  
from flask import render_template


print("Hi from app.py")

# creates a Flask application, named app
app = Flask(__name__, static_url_path='/static')

@app.route("/")
def index():  
    return render_template('index.html')

# run the application
if __name__ == "__main__":  
    app.run(host="0.0.0.0", debug=True)

index.html

<!doctype html>
<html>
<head>
  <title>BOT</title>
</head>
<body>
<script>!(function () {
  let e = document.createElement("script"),
    t = document.head || document.getElementsByTagName("head")[0];
  (e.src =
    "https://cdn.jsdelivr.net/npm/rasa-webchat@1.0.1/lib/index.js"),
    // Replace 1.x.x with the version that you want
    (e.async = !0),
    (e.onload = () => {
      window.WebChat.default(
        {
          customData: { language: "en" },
          socketUrl: "http://localhost:5005",
          // add other props here
        },
        null
      );
    }),
    t.insertBefore(e, t.firstChild);
})();
</script>
</body>
</html>

@Sagar_Indian Sagar you need to update your code, let me guide you.

Step1: You need first fix the code for rasa and rasa-sdk dockerfile and docker-compose. Please refer this link Dockerizing my rasa chatbot application that has botfront - #11 by nik202

Step2: Check you are able to run the docker image on port 5005 for rasa server and 5055 for rasa sdk, not you need to provide root acces and expose 5005 and 5055 as mention in above thread and also provide USER 1001.

Step3: Then try to deploy using rasa-webchat and flask app. If you deploying on a website you should only use rasa webchat snippet code.

Note: you did not mention the rasa-sdk image in the docker file and in the endpoint you mentioned 5055. Docker image can be built in various ways but please do ref above thread.

If you have any doubts or issues please let me know. I hope you will be able to solve it now. Good Luck!

Thanks @nik202 ! how to run custom action? because i am getting this exception.

Traceback (most recent call last):
  File "/home/sagar/.local/lib/python3.8/site-packages/rasa/core/processor.py", line 772, in _run_action
    events = await action.run(
  File "/home/sagar/.local/lib/python3.8/site-packages/rasa/core/actions/action.py", line 717, in run
    raise RasaException("Failed to execute custom action.")
rasa.shared.exceptions.RasaException: Failed to execute custom action.

Hi @Sagar_Indian I had already mention everything in above thread and please check my above thread related to docker. Please see and try adopt that.