frappe_docker icon indicating copy to clipboard operation
frappe_docker copied to clipboard

frappe_docker_websocket service failed

Open kiragoo opened this issue 11 months ago • 3 comments

Description of the issue

First of all, tks for all of contributers.It's my first to use the erpnext.

Context information (for bug reports)

According to the setup_for_linux_mac.md in the main branch to start the app.

The error logs show below:

websocket_1     |     at Socket.emit (node:events:513:28)
websocket_1     |     at emitErrorNT (node:internal/streams/destroy:157:8)
websocket_1     |     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
websocket_1     |     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
websocket_1     |   errno: -111,
websocket_1     |   code: 'ECONNREFUSED',
websocket_1     |   syscall: 'connect',
websocket_1     |   address: '127.0.0.1',
websocket_1     |   port: 12311
websocket_1     | }
frappe_docker_websocket_1 exited with code 1
websocket_1     | node:events:491
websocket_1     |       throw er; // Unhandled 'error' event
websocket_1     |       ^
websocket_1     | 
websocket_1     | Error: connect ECONNREFUSED 127.0.0.1:12311
websocket_1     |     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16)
websocket_1     | Emitted 'error' event on RedisClient instance at:
websocket_1     |     at RedisClient.on_error (/home/frappe/frappe-bench/apps/frappe/node_modules/redis/index.js:342:14)
websocket_1     |     at Socket.<anonymous> (/home/frappe/frappe-bench/apps/frappe/node_modules/redis/index.js:223:14)
websocket_1     |     at Socket.emit (node:events:513:28)
websocket_1     |     at emitErrorNT (node:internal/streams/destroy:157:8)
websocket_1     |     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
websocket_1     |     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
websocket_1     |   errno: -111,
websocket_1     |   code: 'ECONNREFUSED',
websocket_1     |   syscall: 'connect',
websocket_1     |   address: '127.0.0.1',
websocket_1     |   port: 12311
websocket_1     | }
frappe_docker_websocket_1 exited with code 1
websocket_1     | node:events:491
websocket_1     |       throw er; // Unhandled 'error' event
websocket_1     |       ^
websocket_1     | 
websocket_1     | Error: connect ECONNREFUSED 127.0.0.1:12311
websocket_1     |     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16)
websocket_1     | Emitted 'error' event on RedisClient instance at:
websocket_1     |     at RedisClient.on_error (/home/frappe/frappe-bench/apps/frappe/node_modules/redis/index.js:342:14)
websocket_1     |     at Socket.<anonymous> (/home/frappe/frappe-bench/apps/frappe/node_modules/redis/index.js:223:14)
websocket_1     |     at Socket.emit (node:events:513:28)
websocket_1     |     at emitErrorNT (node:internal/streams/destroy:157:8)
websocket_1     |     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
websocket_1     |     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
websocket_1     |   errno: -111,
websocket_1     |   code: 'ECONNREFUSED',
websocket_1     |   syscall: 'connect',
websocket_1     |   address: '127.0.0.1',
websocket_1     |   port: 12311
websocket_1     | }

The status of docker shows below:

CONTAINER ID   IMAGE                COMMAND                  CREATED          STATUS                          PORTS                    NAMES
6cbbbc6b4dd1   frappe/erpnext:v14   "node /home/frappe/f…"   17 minutes ago   Restarting (1) 50 seconds ago                            frappe_docker_websocket_1
1d77afedae2c   frappe/erpnext:v14   "bench schedule"         17 minutes ago   Up 17 minutes                                            frappe_docker_scheduler_1
62946aeebe54   redis:6.2-alpine     "docker-entrypoint.s…"   17 minutes ago   Up 17 minutes                   6379/tcp                 frappe_docker_redis-queue_1
a97b19467a85   frappe/erpnext:v14   "bench worker --queu…"   17 minutes ago   Up 17 minutes                                            frappe_docker_queue-long_1
3a6180a2fabb   frappe/erpnext:v14   "bench worker --queu…"   17 minutes ago   Up 17 minutes                                            frappe_docker_queue-short_1
7216ee791480   frappe/erpnext:v14   "/home/frappe/frappe…"   17 minutes ago   Up 17 minutes                                            frappe_docker_backend_1
b19fbe7acae5   frappe/erpnext:v14   "nginx-entrypoint.sh"    17 minutes ago   Up 17 minutes                   0.0.0.0:8080->8080/tcp   frappe_docker_frontend_1
b02aa5a3e301   redis:6.2-alpine     "docker-entrypoint.s…"   17 minutes ago   Up 17 minutes                   6379/tcp                 frappe_docker_redis-cache_1
c742763bd886   mariadb:10.6         "docker-entrypoint.s…"   17 minutes ago   Up 17 minutes (healthy)         3306/tcp                 frappe_docker_db_1
ece979f4cf71   redis:7.0.4          "docker-entrypoint.s…"   4 months ago     Up 42 minutes                   0.0.0.0:6379->6379/tcp   redis
image Maybe something wrong with the redisclient. ## Steps to reproduce the issue
  1. git clone https://github.com/frappe/frappe_docker
  2. add platform: linux/amd64 to all services in the /pwd.yaml and cp the pwd.yml to /mac.yml
  3. docker-compose -f ./mac.yml up

Observed result

Can't start the services successfully.

Expected result

Start the app successfully.

Stacktrace / full error message if available

(paste here)

I will be appreciate anyone help 😊.

kiragoo avatar Mar 19 '24 03:03 kiragoo

if common_site_config.json doesn't have redis_queue key socketio defaults to localhost:12311 for redis.

point the key to correct service. redis://redis-queue:6379

revant avatar Mar 19 '24 05:03 revant

if common_site_config.json doesn't have redis_queue key socketio defaults to localhost:12311 for redis.

point the key to correct service. redis://redis-queue:6379

Tks @revant , the mac.yml is a copy from pwd.yml which already set the configuration about the redis_queue. The details about the mac.yml as follows:

version: "3"

services:
  backend:
    image: frappe/erpnext:v14
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: on-failure
    volumes:
      - sites:/home/frappe/frappe-bench/sites
      - logs:/home/frappe/frappe-bench/logs

  configurator:
    image: frappe/erpnext:v14
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: none
    entrypoint:
      - bash
      - -c
    command:
      - >
        ls -1 apps > sites/apps.txt;
        bench set-config -g db_host $$DB_HOST;
        bench set-config -gp db_port $$DB_PORT;
        bench set-config -g redis_cache "redis://$$REDIS_CACHE";
        bench set-config -g redis_queue "redis://$$REDIS_QUEUE";
        bench set-config -gp socketio_port $$SOCKETIO_PORT;
    environment:
      DB_HOST: db
      DB_PORT: "3306"
      REDIS_CACHE: redis-cache:6379
      REDIS_QUEUE: redis-queue:6379
      SOCKETIO_PORT: "9000"
    volumes:
      - sites:/home/frappe/frappe-bench/sites
      - logs:/home/frappe/frappe-bench/logs

  create-site:
    image: frappe/erpnext:v14
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: none
    volumes:
      - sites:/home/frappe/frappe-bench/sites
      - logs:/home/frappe/frappe-bench/logs
    entrypoint:
      - bash
      - -c
    command:
      - >
        wait-for-it -t 120 db:3306;
        wait-for-it -t 120 redis-cache:6379;
        wait-for-it -t 120 redis-queue:6379;
        export start=`date +%s`;
        until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \
          [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \
          [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_queue // empty"` ]];
        do
          echo "Waiting for sites/common_site_config.json to be created";
          sleep 5;
          if (( `date +%s`-start > 120 )); then
            echo "could not find sites/common_site_config.json with required keys";
            exit 1
          fi
        done;
        echo "sites/common_site_config.json found";
        bench new-site --no-mariadb-socket --admin-password=admin --db-root-password=admin --install-app erpnext --set-default frontend;

  db:
    image: mariadb:10.6
    platform: linux/amd64
    healthcheck:
      test: mysqladmin ping -h localhost --password=admin
      interval: 1s
      retries: 15
    deploy:
      restart_policy:
        condition: on-failure
    command:
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
      - --skip-character-set-client-handshake
      - --skip-innodb-read-only-compressed # Temporary fix for MariaDB 10.6
    environment:
      MYSQL_ROOT_PASSWORD: admin
    volumes:
      - db-data:/var/lib/mysql

  frontend:
    image: frappe/erpnext:v14
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: on-failure
    command:
      - nginx-entrypoint.sh
    environment:
      BACKEND: backend:8000
      FRAPPE_SITE_NAME_HEADER: frontend
      SOCKETIO: websocket:9000
      UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1
      UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
      UPSTREAM_REAL_IP_RECURSIVE: "off"
      PROXY_READ_TIMEOUT: 120
      CLIENT_MAX_BODY_SIZE: 50m
    volumes:
      - sites:/home/frappe/frappe-bench/sites
      - logs:/home/frappe/frappe-bench/logs
    ports:
      - "8080:8080"

  queue-long:
    image: frappe/erpnext:v14
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: on-failure
    command:
      - bench
      - worker
      - --queue
      - long
    volumes:
      - sites:/home/frappe/frappe-bench/sites
      - logs:/home/frappe/frappe-bench/logs

  queue-short:
    image: frappe/erpnext:v14
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: on-failure
    command:
      - bench
      - worker
      - --queue
      - short
    volumes:
      - sites:/home/frappe/frappe-bench/sites
      - logs:/home/frappe/frappe-bench/logs

  redis-queue:
    image: redis:6.2-alpine
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: on-failure
    volumes:
      - redis-queue-data:/data

  redis-cache:
    image: redis:6.2-alpine
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: on-failure
    volumes:
      - redis-cache-data:/data

  scheduler:
    image: frappe/erpnext:v14
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: on-failure
    command:
      - bench
      - schedule
    volumes:
      - sites:/home/frappe/frappe-bench/sites
      - logs:/home/frappe/frappe-bench/logs

  websocket:
    image: frappe/erpnext:v14
    platform: linux/amd64
    deploy:
      restart_policy:
        condition: on-failure
    command:
      - node
      - /home/frappe/frappe-bench/apps/frappe/socketio.js
    volumes:
      - sites:/home/frappe/frappe-bench/sites
      - logs:/home/frappe/frappe-bench/logs

volumes:
  db-data:
  redis-queue-data:
  redis-cache-data:
  sites:
  logs:

In the other way, i checked the common_site_config.json on the shared volumes sites. The content of common_site_config.json in the container of frappe_docker_scheduler as follow:

frappe@0e003418cbb5:~/frappe-bench/sites$ ls
apps.json  apps.txt  assets  common_site_config.json  currentsite.txt  frontend
frappe@0e003418cbb5:~/frappe-bench/sites$ cat common_site_config.json
{
 "db_host": "db",
 "db_port": 3306,
 "redis_cache": "redis://redis-cache:6379",
 "redis_queue": "redis://redis-queue:6379",
 "socketio_port": 9000
}

Tks for your help!!😊

kiragoo avatar Mar 19 '24 08:03 kiragoo