docker4drupal icon indicating copy to clipboard operation
docker4drupal copied to clipboard

Can not get Drupal-node working, getting Invalid service key undefined

Open timdiels1 opened this issue 5 years ago • 4 comments

Codebase Mounted codebase

Describe the bug I would like to get the ajax_comments working with Drupal 8. Applied patch from https://www.drupal.org/project/ajax_comments/issues/3031187 for NodeJS integration. But first trying to get the nodejs module working and send a broadcast message. There it fails and gives me the error Invalid service key undefined, expecting node-service-key

Output of docker info

Client:
 Debug Mode: false

Server:
 Containers: 8
  Running: 8
  Paused: 0
  Stopped: 0
 Images: 52
 Server Version: 19.03.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.9.184-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.787GiB
 Name: docker-desktop
 ID: 7PCQ:OOE4:4RSP:KDUX:2SAE:62VP:PRYV:RO7O:APEW:X6R6:FXE2:Z2JL
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 226
  Goroutines: 241
  System Time: 2020-02-28T11:03:19.8839034Z
  EventsListeners: 11
 HTTP Proxy: gateway.docker.internal:3128
 HTTPS Proxy: gateway.docker.internal:3129
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

Contents of your docker-compose.yml

version: "3"

services:
  mariadb:
    image: wodby/mariadb:$MARIADB_TAG
    container_name: "${PROJECT_NAME}_mariadb"
    stop_grace_period: 30s
    environment:
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD
    ports:
      - 3306

  php:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_php"
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025  
      DB_HOST: $DB_HOST
      DB_PORT: $DB_PORT
      DB_USER: $DB_USER
      DB_PASSWORD: $DB_PASSWORD
      DB_NAME: $DB_NAME
      DB_DRIVER: $DB_DRIVER
      PHP_FPM_USER: wodby
      PHP_FPM_GROUP: wodby
      COLUMNS: 80 # Set 80 columns for docker exec -it.
    volumes:
      - ./../:/var/www/html:cached # User-guided caching

  nginx:
    image: wodby/nginx:$NGINX_TAG
    container_name: "${PROJECT_NAME}_nginx"
    depends_on:
      - php
    environment:
      NGINX_STATIC_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
      NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET
    volumes:
      - ./../:/var/www/html:cached # User-guided caching
    labels:
      - "traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`)"

  mailhog:
    image: mailhog/mailhog
    container_name: "${PROJECT_NAME}_mailhog"
    labels:
      - "traefik.http.services.${PROJECT_NAME}_mailhog.loadbalancer.server.port=8025"
      - "traefik.http.routers.${PROJECT_NAME}_mailhog.rule=Host(`mailhog.${PROJECT_BASE_URL}`)"

  drupal-node:
    image: wodby/drupal-node:$DRUPAL_NODE_TAG
    container_name: "${PROJECT_NAME}_drupal_nodejs"
    environment:
      NODE_SERVICE_KEY: node-service-key
      NODE_DEBUG: 1
      NODE_BACKEND_PORT: 8080
      NODE_BACKEND_HOST: drupal-node
    labels:
      - "traefik.http.routers.${PROJECT_NAME}_drupal_node.rule=Host(`drupal_node.${PROJECT_BASE_URL}`)"
    command: sh -c 'npm install && node app.js'

  portainer:
    image: portainer/portainer
    container_name: "${PROJECT_NAME}_portainer"
    command: --no-auth -H unix:///var/run/docker.sock
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - "traefik.http.routers.${PROJECT_NAME}_portainer.rule=Host(`portainer.${PROJECT_BASE_URL}`)"

  traefik:
    image: traefik:v2.0
    container_name: "${PROJECT_NAME}_traefik"
    command: --api.insecure=true --providers.docker
    ports:
      - '8000:80'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Contents of your .env

### Documentation available at https://wodby.com/docs/stacks/drupal/local
### Changelog can be found at https://github.com/wodby/docker4drupal/releases
### Images tags format explained at https://github.com/wodby/docker4drupal#images-tags

### PROJECT SETTINGS

PROJECT_NAME=drupal8
PROJECT_BASE_URL=drupal8.docker.localhost

DB_NAME=drupal
DB_USER=drupal
DB_PASSWORD=drupal
DB_ROOT_PASSWORD=password
DB_HOST=mariadb
DB_PORT=3306
DB_DRIVER=mysql

### --- MARIADB ----

MARIADB_TAG=10.4-3.7.6
#MARIADB_TAG=10.3-3.7.6
#MARIADB_TAG=10.2-3.7.6
#MARIADB_TAG=10.1-3.7.6

### --- VANILLA DRUPAL ----

DRUPAL_TAG=8-4.17.2
#DRUPAL_TAG=7-4.17.2

### --- PHP ----

# Linux (uid 1000 gid 1000)

PHP_TAG=7.3-dev-4.15.1
#PHP_TAG=7.2-dev-4.15.1
#PHP_TAG=7.4-dev-4.15.1

# macOS (uid 501 gid 20)

#PHP_TAG=7.3-dev-macos-4.15.1
#PHP_TAG=7.2-dev-macos-4.15.1
#PHP_TAG=7.4-dev-macos-4.15.1

### --- NGINX ----

NGINX_TAG=1.17-5.8.6
#NGINX_TAG=1.16-5.8.6

NGINX_VHOST_PRESET=drupal8
#NGINX_VHOST_PRESET=drupal7
#NGINX_VHOST_PRESET=drupal6

### --- SOLR ---

SOLR_CONFIG_SET="search_api_solr_8.x-3.2"
#SOLR_CONFIG_SET="search_api_solr_8.x-2.7"
#SOLR_CONFIG_SET="search_api_solr_8.x-1.2"
#SOLR_CONFIG_SET="search_api_solr_7.x-1.14"

SOLR_TAG=8-4.4.1
#SOLR_TAG=7-4.4.1
#SOLR_TAG=6-4.4.1
#SOLR_TAG=5-4.4.1

### --- ELASTICSEARCH ---

ELASTICSEARCH_TAG=7-5.4.0
#ELASTICSEARCH_TAG=6-5.4.0

### --- KIBANA ---

KIBANA_TAG=7-5.4.0
#KIBANA_TAG=6-5.4.0

### --- REDIS ---

REDIS_TAG=4-3.2.2
#REDIS_TAG=5-3.2.2

### --- NODE ---

NODE_TAG=12-dev-0.33.1
#NODE_TAG=10-dev-0.33.1
#NODE_TAG=8-dev-0.33.1

### --- VARNISH ---

VARNISH_TAG=6.0-4.4.4
#VARNISH_TAG=4.1-4.4.4

### --- POSTGRESQL ----

POSTGRES_TAG=12-1.9.1
#POSTGRES_TAG=11-1.9.1
#POSTGRES_TAG=10-1.9.1
#POSTGRES_TAG=9.6-1.9.1
#POSTGRES_TAG=9.5-1.9.1
#POSTGRES_TAG=9.4-1.9.1

### OTHERS

ADMINER_TAG=4-3.9.4
APACHE_TAG=2.4-4.2.3
ATHENAPDF_TAG=2.10.0
DRUPAL_NODE_TAG=1.0-2.0.0
MEMCACHED_TAG=1-2.4.1
OPENSMTPD_TAG=6.0-1.6.3
RSYSLOG_TAG=latest
SELENIUM_CHROME_TAG=3.141
WEBGRIND_TAG=1-1.14.3
XHPROF_TAG=2.1.3

Logs output docker-compose logs

[2020/02/28 10:58:58] publishMessageToContentChannel: The channel watchdog_dblog doesn't exist.
[2020/02/28 10:58:59] authenticateClient: Authenticating client with key 89267e8a012013598d28487759a35866
[2020/02/28 10:58:59] Sending message to backend
[2020/02/28 10:58:59] message
{ authToken: '89267e8a012013598d28487759a35866',
  messageType: 'authenticate',
  clientId: 'NR9uyJK74gOEJKtkAAAB' }
[2020/02/28 10:58:59] options
{ uri: 'http://drupal-node:8080/nodejs/message',
  body: 'messageJson=%7B%22authToken%22%3A%2289267e8a012013598d28487759a35866%22%2C%22messageType%22%3A%22authenticate%22%2C%22clientId%22%3A%22NR9uyJK74gOEJKtkAAAB%22%7D&serviceKey=node-service-key',
  headers:
   { 'Content-Length': 205,
     'Content-Type': 'application/x-www-form-urlencoded' } }
[2020/02/28 10:58:59] Route callback: checkServiceKey
[2020/02/28 10:58:59] checkServiceKey: Invalid service key undefined, expecting node-service-key
[2020/02/28 10:58:59] authenticateClientCallback: Call failed: Invalid service key.
[2020/02/28 10:58:59] cleanupSocket: Cleaning up after socket id NR9uyJK74gOEJKtkAAAB, uid undefined

timdiels1 avatar Feb 28 '20 11:02 timdiels1

There should be no command in drupal-node service, that's probably the issue

csandanov avatar Feb 28 '20 11:02 csandanov

although the default command is already node app.js, so probably not the issue after all

csandanov avatar Feb 28 '20 11:02 csandanov

Tried to reproduce with vanilla D8, connected insecure over http with the default service key and it works fine. The module reports as connected but insecure. Please note if you want to set a secure connection you should generate a certificate.

csandanov avatar Feb 28 '20 11:02 csandanov

The module to me reports also as connected but insecure, but the logs in docker-node tells me the message could not be processed because of "Invalid service key"

timdiels1 avatar Feb 28 '20 12:02 timdiels1