Docker Community Forums

Share and learn in the Docker community.

Docker scoketIO, how to set up?

I’m running Rasa chatbot in container and also Apache2 web server. I use Botfront Webchat as chat widget. Webchat communicates with Rasa via socketIO. I can get it working when Apache is outside container i.e. installed normally and Rasa running in container. But when I start both them in container, chatbot doesn’t reply any more. Chatbot opens but when I type question to bot, nothing happens?!

Here is my docker-compose file

linttu@linttu-VirtualBox:~/rasa$ cat docker-compose.yml 
version: '3.0'
services:
  rasa:
    container_name: rasaPauli
    #image: rasa/rasa:2.4.1-full
    image: rasa/rasa:1.10.11-full
    ports:
      - 5005:5005
      #- 5002:5010
    volumes:
     # - ./rasa_v2:/app
      - ./rasa_v1:/app
    command:
      - run
      - -m models
      - --enable-api
      - --cors
      - "*"
      - --debug

  apache:
    image: docker.io/bitnami/apache:2.4-debian-10
    ports:
      - 80:8080
      - 443:8443
    volumes:
      - ./web:/app

I can see socketio starting from Rasa debug

rasaPauli | 2021-03-25 10:35:53 INFO     root  - Rasa server is up and running.
rasaPauli | 2021-03-25 10:35:54 DEBUG    rasa.core.channels.socketio  - User ed20c02335aa435fb9ee8793a5e4cdda connected to socketIO endpoint.
rasaPauli | 2021-03-25 10:35:54 DEBUG    rasa.core.channels.socketio  - User ed20c02335aa435fb9ee8793a5e4cdda connected to socketIO endpoint.

Here some analysis

linttu@linttu-VirtualBox:~/rasa$ sudo netstat -plant
[sudo] password for linttu: 
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      304/systemd-resolve 
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      4535/cupsd          
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      11556/docker-proxy  
tcp        0      0 0.0.0.0:5005            0.0.0.0:*               LISTEN      11961/docker-proxy  
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      11581/docker-proxy  
tcp        0      0 127.0.0.1:5005          127.0.0.1:54950         ESTABLISHED 11961/docker-proxy  
tcp        0      0 127.0.0.1:54950         127.0.0.1:5005          ESTABLISHED 10989/firefox       
tcp        0      0 10.0.2.15:53444         52.33.6.204:443         ESTABLISHED 10989/firefox       
tcp        0      0 172.18.0.1:39478        172.18.0.2:5005         ESTABLISHED 11961/docker-proxy  
tcp6       0      0 ::1:631                 :::*                    LISTEN      4535/cupsd  

and this

linttu@linttu-VirtualBox:~/rasa$ sudo ss -nltp
State       Recv-Q       Send-Q                Local Address:Port               Peer Address:Port                                                        
LISTEN      0            128                   127.0.0.53%lo:53                      0.0.0.0:*           users:(("systemd-resolve",pid=304,fd=13))       
LISTEN      0            5                         127.0.0.1:631                     0.0.0.0:*           users:(("cupsd",pid=4535,fd=7))                 
LISTEN      0            4096                        0.0.0.0:443                     0.0.0.0:*           users:(("docker-proxy",pid=11556,fd=4))         
LISTEN      0            4096                        0.0.0.0:5005                    0.0.0.0:*           users:(("docker-proxy",pid=11961,fd=4))         
LISTEN      0            4096                        0.0.0.0:80                      0.0.0.0:*           users:(("docker-proxy",pid=11581,fd=4))         
LISTEN      0            5                             [::1]:631                        [::]:*           users:(("cupsd",pid=4535,fd=6))          

Here is my index file which starts chatbot

linttu@linttu-VirtualBox:~/rasa$ cat web/index.html 
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <script src="https://cdn.jsdelivr.net/npm/rasa-webchat@0.11.12/lib/index.min.js"></script>
    <link rel="stylesheet" type="text/css" href="st.css">
</head>
<body>
testi
<div id="webchat"></div>
<script>
  WebChat.default.init({
    selector: "#webchat",
    initPayload: "/tervetuloa",
    customData: {"language": "fi"}, // arbitrary custom data. Stay minimal as this will be added to the socket
    socketUrl: "http://localhost:5005",
    socketPath: "/socket.io/",
    embedded: false,
    title: "Webottinen",
    subtitle: "Omnian webot hankkeen UKK botti",
    inputTextFieldHint: "Kirjoita kysymys tähän...",
    //profileAvatar: "robot_icon.png",
    params: {"storage": "session"} // can be set to "local"  or "session". details in storage section.
  })
</script>
</body>
</html>

Configure your project. …
Install express and start the server. …
Install Socket.io library. …
Create a form to enter the message. …
Make a socket connection. …
Listen to the send message event. …
Run the project. …
Setup Docker.

thank you for your reply but I don’t understand your instructions?