Rasa-x setup in aws with http port

Hello, I have setup rasa-x on aws using docker compose, the container is working fine. I can connect to rasa-x from my browser.

I want to connect to the instance from chat widget, example: https://github.com/JiteshGaikwad/Chatbot-Widget The widget uses http:host:5005 However the rasa-x setup on aws does not seem to have http port working. Above url returned nothing. on looking on docker ps on aws:

ubuntu@i/etc/rasa$ sudo docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED       STATUS                    PORTS                                                                                    NAMES
692fb330ff1b   nginx:1.19                   "/docker-entrypoint.…"   6 weeks ago   Up 13 minutes             80/tcp, 0.0.0.0:80->8080/tcp, :::80->8080/tcp, 0.0.0.0:443->8443/tcp, :::443->8443/tcp   rasa_nginx_1
51aaf03831a0   rasa/rasa-sdk:latest         "./entrypoint.sh sta…"   6 weeks ago   Up 13 minutes             5055/tcp                                                                                 rasa_app_1
e87ee9e4fee4   rasa/rasa:2.8.11-full        "rasa x --no-prompt …"   6 weeks ago   Up 13 minutes             5005/tcp                                                                                 rasa_rasa-worker_1
6fde7df15ac5   rasa/rasa:2.8.11-full        "rasa x --no-prompt …"   6 weeks ago   Up 13 minutes             5005/tcp                                                                                 rasa_rasa-production_1
48d1d2610657   rasa/rasa-x:0.42.4           "python -m rasax.com…"   6 weeks ago   Up 13 minutes (healthy)   8000/tcp                                                                                 rasa_db-migration_1
61eff649cb74   rasa/rasa-x:0.42.4           "/tini -g -- sh -c '…"   6 weeks ago   Up 13 minutes             5002/tcp                                                                                 rasa_rasa-x_1
227b66faf14a   bitnami/postgresql:11.11.0   "/opt/bitnami/script…"   6 weeks ago   Up 13 minutes             5432/tcp                                                                                 rasa_db_1
a5d45fdfe626   bitnami/rabbitmq:3.8.17      "/opt/bitnami/script…"   6 weeks ago   Up 13 minutes             4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp                                      rasa_rabbit_1
05b666f9c8f5   rasa/duckling:0.1.6.5-r2     "duckling-example-ex…"   6 weeks ago   Up 13 minutes             8000/tcp                                                                                 rasa_duckling_1
f0727118c0ba   bitnami/redis:6.2.4          "/opt/bitnami/script…"   6 weeks ago   Up 13 minutes             6379/tcp                                                                                 rasa_redis_1

In case of my local setup, if I do http://localhost:5005 I get response from Rasa. What do I need to do in the docker-compose setup to expose http port to integrate it with chatbot widget.

thank you.

@ashek1520 alright, the issue is port number please use port 8000 instead 5005. Do let me know if it’s working or not?

Hi, thanks for your reply. 8000 did not work. I tried http://host_ip:8000 received:

Firefox can’t establish a connection to the server at 54.71.76.226:8000.

The site could be temporarily unavailable or too busy. Try again in a few moments.

If I use http://host_ip:80 This connects to rasa-X

@ashek1520 can you do the open trick, use ngrok run on server-side and use that link for port 8000

ngrok http 80 or ./ngrok http 80 use only https link

In general Rasa x need DNS and HTTPS secure channel

Always mention @ and nik202 for fast reply.

@nik202 I guess you meant to run ngrok on aws vm, right? On AWS VM, I install ngrok, and ran ngrok http 8000 Got this:

Forwarding                    http://26f3-52-12-70-138.ngrok.io -> http://localhost:8000                                                                                                                                                                                                                        
Forwarding                    https://26f3-52-12-70-138.ngrok.io -> http://localhost:8000

I tired to open both the links, but got

The connection to **https://26f3-52-12-70-138.ngrok.io** was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address **[localhost:8000](http://localhost:8000)**.

On the ngrok client, got

502 Bad Gateway

I believe the problem is in my rasa setup. Do I need to do anything in the config file?

in my credential.yml

rasa:
  url: ${RASA_X_HOST}/api
rest:

Seems like some issue in my setup, is there any otherway we can check locally if the rest port is ready on vm on ubuntu the listening ports:

ubuntu@$ sudo lsof -i -P -n | grep LISTEN
systemd-r  687 systemd-resolve   13u  IPv4  18000      0t0  TCP 127.0.0.53:53 (LISTEN)
sshd       886            root    3u  IPv4  20124      0t0  TCP *:22 (LISTEN)
sshd       886            root    4u  IPv6  20144      0t0  TCP *:22 (LISTEN)
docker-pr 1673            root    4u  IPv4  25149      0t0  TCP *:443 (LISTEN)
docker-pr 1680            root    4u  IPv6  25154      0t0  TCP *:443 (LISTEN)
docker-pr 1709            root    4u  IPv4  25661      0t0  TCP *:80 (LISTEN)
docker-pr 1714            root    4u  IPv6  25185      0t0  TCP *:80 (LISTEN)

There is no 8000 port open for listening.

@ashek1520 Thanks for the feedback. Yes, If you are using socketIO you need to mention the socketio in the credentials.yml in docker i.e

socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true

Please check your local setup, I’m sure you have mentioned this in credentials.yml that why you are able to run the widget on port 5005.

Ref: Your Own Website

Please make the necessary changes and spin the docker. I guess this time you will be able to see the bot on your website. Please let me know your progress and wish you and your family happy new year 2022. Good Luck!

@nik202 Happy new year to you too :slight_smile: I have setup rasa locally, but without docker-compose. In my local rasa, I have only

rasa:
  url: "http://localhost:5002/api"
rest:

In my local machine, I run rasa as rasa --enable-api --cors "*", this open listen port

rasa      1419618        abhishek   15u  IPv4 16851007      0t0  TCP *:5005 (LISTEN)

I don’t think I need socketio, I need somehow to tell rasa to open in --enable-api model. this will probably open listen port too for 5005. I do not need socketio to connect to the aforementioned chatbot widget to the rasa. When we start Rasa, (I think) it opens up 5005 default port, that’s why I was expecting it to connect to 5005.

Do I still need socketio?In the chatbot widget

url: `http://localhost:5005/conversations/${sender_id}/execute`

@ashek1520 Ok. Then you expose 5005 using ngrok and do let me know please.

@nik202 First of all, thanks for all your replies. “ngrok http 5005” does not help. I think ngrok can only help I guess, when 5005 is exposed out of docker containers. At present, no listen port is open on the host for 5005, so ngrok will not be able to help. on the shell of AWS instance:

ubuntu@:~$ curl https://localhost:5005
curl: (7) Failed to connect to localhost port 5005: Connection refused
# Same for HTTP

I looked at sudo docker ps

sudo docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED       STATUS                 PORTS                                                                                    NAMES
692fb330ff1b   nginx:1.19                   "/docker-entrypoint.…"   7 weeks ago   Up 2 hours             80/tcp, 0.0.0.0:80->8080/tcp, :::80->8080/tcp, 0.0.0.0:443->8443/tcp, :::443->8443/tcp   rasa_nginx_1
51aaf03831a0   rasa/rasa-sdk:latest         "./entrypoint.sh sta…"   7 weeks ago   Up 2 hours             5055/tcp                                                                                 rasa_app_1
e87ee9e4fee4   rasa/rasa:2.8.11-full        "rasa x --no-prompt …"   7 weeks ago   Up 2 hours             5005/tcp                                                                                 rasa_rasa-worker_1
6fde7df15ac5   rasa/rasa:2.8.11-full        "rasa x --no-prompt …"   7 weeks ago   Up 2 hours             5005/tcp                                                                                 rasa_rasa-production_1
----- More containers ---

Clearly nginx is not mapping every ports, I tried to change docker-compose.yml so that it can expose 5005 port as well.

nginx:
    restart: always
    image: "nginx:1.19"
    ports:
      - "80:8080"
      - "443:8443"
      - "5005:5005"   <----- Added theselines
      - "8000:8000"   <----- Added these lines
    volumes:
      - ./certs:/etc/certs
      - ./nginx-config-files/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx-config-files/ssl.conf.template:/etc/nginx/templates/ssl.conf.template
      - ./nginx-config-files/rasax.nginx.template:/etc/nginx/templates/rasax.nginx.template
    environment:
      <<: *nginx-host-variables
    depends_on:
      - rasa-x
      - rasa-production
      - app

Did docker stop and docker start, but that did not change on list of ports in ‘docker ps’ for nginx container… any thought on it. Do I need to do any other changes?

@nik202 thanks for helping in reaching to the solution No need to make any change to Nginx. In the AWS VM, run ngrok HTTP 5005 which gives something like:

ngrok by @inconshreveable                                                                                                                                                                                                                                                                       (Ctrl+C to quit)
                                                                                                                                                                                                                                                                                                                
Session Status                online                                                                                                                                                                                                                                                                            
Session Expires               1 hour, 44 minutes                                                                                                                                                                                                                                                                
Version                       2.3.40                                                                                                                                                                                                                                                                            
Region                        United States (us)                                                                                                                                                                                                                                                                
Web Interface                 http://127.0.0.1:4040                                                                                                                                                                                                                                                             
Forwarding                    http://xxxx-xx-xx-xx-xxx.ngrok.io -> http://localhost:5005                                                                                                                                                                                                                        
Forwarding                    https://xxxx-xx-xx-xx-xxx.ngrok.io -> http://localhost:5005                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                
Connections                   ttl     opn     rt1     rt5     p50     p90                                                                                                                                                                                                                                       
                              4       0       0.00    0.00    0.00    0.00  

in the chatbot widget->chat.js in Action trigger: replace http://localhost by https://xxxx-xx-xx-xx-xxx.ngrok.io Observation: the chatbot works even if I used http

After this, if open index.html, I could connect to the rasa on AWS instance. However, I still have a problem in connection to the action server. I tried to do the same with 5055 port ran ngrok HTTP 5055 and used the https link in place of localhost in customActionTrigger in the chatbot widget->chat.js, but that did not help.

@ashek1520 That’s great Abhishek!

Few Observations from my side:

  1. If you are using ngrok just create the ngrok account, authenticate the tokens and then session expires will be free 24/7
  2. I’d recommend to use only https for the port forwarding as it’s more secure.
  3. You can even try the Rasa/webchat integration as we had discussed, please see this video for your reference: Rasa chatbot website integration | Quick tutorial - YouTube
  4. I guess you are using docker for the rasa x installation, you can directly pull the action server image from the docker registry and use in docker-compose.overide.yml file
  5. We had run the ngrok on port 80 and it was giving us the result then why you need to expose 5005? as you are using docker and rasa x? For local ROS we expose the 5005 and for server side we expose port 80. Note: I guess you need to update some files in the endpoints.yml for the actions server to spin or we can discuss more.

If you have any further doubt please feel free to share with me. Good Luck!

Hi @ashek1520 Can I request to close this thread as a solution? Thanks.