Announcement

Collapse
No announcement yet.

Docker setup, websocket not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Docker setup, websocket not working

    Hi. I've setup EspoCRM in a docker environment. Everything except websocket is working. Now been banging my head against the issue too long and any help would be appreciated.

    Using docker-compose:
    Code:
    version: "2.2"
    services:
    espocrm:
    image: espocrm/espocrm
    container_name: espocrm
    environment:
    ESPOCRM_DATABASE_HOST: 172.17.0.1
    ESPOCRM_DATABASE_USER: dbuser
    ESPOCRM_DATABASE_NAME: dbname
    ESPOCRM_DATABASE_PASSWORD: "dbpass"
    ESPOCRM_ADMIN_USERNAME: admin
    ESPOCRM_ADMIN_PASSWORD: "adminpass"
    ESPOCRM_SITE_URL: "https://crm.domain.tld"
    volumes:
    - ./config/espocrm:/var/www/html
    restart: always
    ports:
    - 127.0.0.1:8038:80
    
    espocrm-daemon:
    image: espocrm/espocrm
    container_name: espocrm-daemon
    volumes:
    - ./config/espocrm:/var/www/html
    restart: always
    entrypoint: docker-daemon.sh
    
    espocrm-websocket:
    image: espocrm/espocrm
    container_name: espocrm-websocket
    environment:
    ESPOCRM_CONFIG_USE_WEB_SOCKET: "true"
    ESPOCRM_CONFIG_WEB_SOCKET_URL: "wss://crm.domain.tld/ws"
    ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBSCRIBER_DSN: "tcp://*:7777"
    ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBMISSION_DSN: "tcp://espocrm-websocket:7777"
    volumes:
    - ./config/espocrm:/var/www/html
    restart: always
    entrypoint: docker-websocket.sh
    ports:
    - 127.0.0.1:8039:8080​

    And Nginx as a reverse proxy:
    Code:
    location / {
       include proxy_params;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "Upgrade";
       proxy_pass http://localhost:8038/;
    }
    
    location /ws {
       proxy_http_version 1.1;
       proxy_buffering off;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "Upgrade";
       proxy_pass http://localhost:8038;
    }​

    I've tried to proxy pass directly to 8039 port as well, but same result where browser is not able to connect. Console output:
    Code:
    autobahn.js:341 WebSocket connection to 'wss://crm.domain.tld/ws?authToken=a8e6a24291d51951e9980116f2b2f480&userId=1' failed:
    ab.Session @ autobahn.js:341
    autobahn.js:341 WebSocket connection to 'wss://crm.domain.tld/ws?authToken=a8e6a24291d51951e9980116f2b2f480&userId=1' failed:
    ab.Session @ autobahn.js:341
    autobahn.js:341 WebSocket connection to 'wss://crm.domain.tld/ws?authToken=a8e6a24291d51951e9980116f2b2f480&userId=1' failed:
    ab.Session @ autobahn.js:341​
    I also tried to connect directly to the socket on the host using wscat (ws instead of wss since its before the proxy), but it might seem there is no socket running in the docker container?
    Code:
    wscat -c ws://127.0.0.1:8038
     - error: Unexpected server response: 200
    
    wscat -c ws://127.0.0.1:8038/ws
     - error: Unexpected server response: 404
    
    wscat -c ws://127.0.0.1:8038/wss
     - error: Unexpected server response: 404
    
    wscat -c ws://127.0.0.1:8039
     - error: Unexpected server response: 426
    
    wscat -c ws://127.0.0.1:8039/ws
     - error: Unexpected server response: 426
    
    wscat -c ws://127.0.0.1:8038/wss
     - error: Unexpected server response: 404

  • #2
    With this kind of software I recommend installing on a (Linux) VM and not with Docker container. Especially if you want to make adjustments, or e.g. have to upgrade PHP. Or if you need help at the forum you always have a slightly different installation than many others here. At least for a production system Espo I would not use Docker.

    Comment


    • #3
      Originally posted by macistda View Post
      With this kind of software I recommend installing on a (Linux) VM and not with Docker container. Especially if you want to make adjustments, or e.g. have to upgrade PHP. Or if you need help at the forum you always have a slightly different installation than many others here. At least for a production system Espo I would not use Docker.
      Thank you for taking your time to answering, but unfortunately it does not help me much with my problem at hand / question per se. As stated, the docker setup works perfectly except for the websockets. I understand that its "new" to dockerize Espo and kind of a best effort / community based part of espocrm. But I would love to find a solution, and guessing others have solved / not experienced problems with this since I cant find much information about it.

      Comment


      • macistda
        macistda commented
        Editing a comment
        I know that was just strategic advice. I use Docker a lot myself.
        In my opinion Docker is well if you have software that doesn't have to be able to do many different things (=microservices) or if you want to provide this type of services in larger environments.
        Hoping that these services do not depend on each other...
        - This is not meant to be a discussion of Podman vs. Docker...

        I guess for Websockets you will have to pass on to from one container to the other one.

    • #4
      Hi,
      i don’t know docker, but maybe
      my sample work

      Hi everyone, i have a problem connecting to the websocket in my espocrm instance. WebSocket connection to 'wss://mydomain/?authToken=0586c18e2007cc616c1869bbd2282062&userId=63d912a067faaa322' failed: The current setup is based on a docker container VM with FPM configuration (nginx-mysql-espocrm-websocket-daemon). The

      Comment


      • #5
        I think my biggest question now is:
        Should my reverse proxy point towards the espocrm main instance (8038) or to the websocket (8039) port?

        Websocket-container is not logging anything at all which seems a bit strange. But if the websocket-request reaches the main instance the container gives:
        Code:
        espocrm              | 192.168.16.1 - - [06/Mar/2023:14:31:12 +0000] "GET /ws?authToken=a8e6a24291d51951e9980116f2b2f480&userId=1 HTTP/1.1" 404 435 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
        espocrm              | 192.168.16.1 - - [06/Mar/2023:14:31:20 +0000] "GET /ws?authToken=a8e6a24291d51951e9980116f2b2f480&userId=1 HTTP/1.1" 404 435 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"​
        Last edited by hrdy90; 03-06-2023, 03:00 PM.

        Comment


        • hrdy90
          hrdy90 commented
          Editing a comment
          And what endpoint url does EspoCRM listen to? The:
          ESPOCRM_CONFIG_WEB_SOCKET_URL: "wss://crm.domain.tld/ws"

          Only seems to tell the browser/client where to direct its websocket request.

        • item
          item commented
          Editing a comment
          if you look my sample,

          i have never somewhere in my config : "wss://crm.domain.tld/ws". <=. at the end /ws !

          i have this :

          location /wss {
          proxy_pass http://websocket;

          this :
          set $upstream BACK_END_VM_IP;

          and this :

          upstream websocket {
          server BACK_END_VM_IP:8080;

        • hrdy90
          hrdy90 commented
          Editing a comment
          I tried your suggestion as well already before posting here. It seems something else must be wrong. I have also created a issue on the GitHub repository as I suspect something else might be wrong but have not heard anything yet https://github.com/espocrm/espocrm-docker/issues/21
      Working...
      X