botfront / rasa-webchat

A feature-rich chat widget for Rasa and Botfront
https://botfront.io/rasa
Apache License 2.0
962 stars 497 forks source link

Issue with Docker compose #320

Closed andrewlu0 closed 3 years ago

andrewlu0 commented 3 years ago

Hi, I am having an issue when separating my React app and Rasa server into two different Docker containers and building with docker compose. Here is my docker-compose.yml:

version: '3.0'

services:
  nginx:
    container_name: "nginx"
    image: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    ports:
      - 80:80
    depends_on: 
      - rasa_server
      - action_server
      - assistant_ui

  duckling:
    image: rasa/duckling:latest
    ports:
    - "8000:8000"

  rasa_server:
    container_name: "rasa_server"
    build:
      context: .
    ports:
    - "5005:5005"
    expose: 
      - 5005

  action_server:
    container_name: "action_server"
    build:
      context: actions
    volumes:
      - ./actions:/app/actions
    ports:
    - "5055:5055"

  assistant_ui:
    container_name: "assistant_ui"
    build:
      context: front
    ports:
    - "3000:3000"

And here is my custom widget:

function CustomWidget (props) {
  return (
    <Widget
      initPayload={"/get_started"}
      socketUrl={"http://rasa_server:5005"}
      socketPath={"/socket.io/"}
      inputTextFieldHint={"Enter a valid command"}
      customData={{"language": "en"}} // arbitrary custom data. Stay minimal as this will be added to the socket
      title={"Virtual Assistant"}
      showFullScreenButton={"true"}
      embedded={"true"}
      hideWhenNotConnected = {"false"}
      params={{"storage": "session"}}
    />
  );
}

I can make pings to the rasa_server container from inside the assistant_ui container but when I open the web page, the chat box is not displayed.

Fugit185 commented 3 years ago

does your credentials.yml have this?

socketio: user_message_evt: user_uttered bot_message_evt: bot_uttered session_persistence: true

andrewlu0 commented 3 years ago

Yes, I included that in my credentials. I found a work around where I start the React app on a separate VM and change

socketUrl={"http://<IP address of backend VM>:5005"}

And that works fine. Just not sure why the containers on the same machine are not connecting

Fugit185 commented 3 years ago

I start my rasa docker container with following command , for example this has to be there --cors "*"

docker run --name=laake --user 1003 -v $(pwd):/app -p "5010:5005" rasa/rasa:1.10.11-full run -m models --enable-api --cors "*" --debug

It allows webservices talk to each other https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS