Giter Site home page Giter Site logo

docker-laravel-echo-server's Introduction

👀 Hello world!

My name is Oanh Nguyen and I'm a software/DevOps engineer.
I'm from Vietnam, living in Hanoi and currently working at Rabiloo Co., Ltd.
You can find me on , or on .

🏢 Rabiloo Co., Ltd

Rabiloo Corporate Video

🔧 Technologies & Tools

📈 GitHub Stats

Metrics

docker-laravel-echo-server's People

Contributors

mwienk avatar nicolaskempf57 avatar oanhnn avatar squareborg avatar vanodevium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

docker-laravel-echo-server's Issues

Could not subscribe to echo server channels

Here is the docker-compose.yml

version: "3.1"
services:
    laravel-echo-server:
      image: oanhnn/laravel-echo-server:2.1.1
      depends_on:
        - redis
      container_name: robocash-echo-server
      ports:
        - 6001:6001
      environment:
        REDIS_HOST: robocash-redis
        LARAVEL_ECHO_SERVER_AUTH_HOST: http://robocash-webserver
        LARAVEL_ECHO_SERVER_DEBUG: 'true'
      networks:
        - robocash

    postgres:
      image: postgres:13
      container_name: robocash-postgres
      healthcheck:
        test: pg_isready
        interval: 5s
        timeout: 10s
        retries: 120
      volumes:
        - .:/application
        - postgres-volume:/var/lib/postgresql/data
      restart: on-failure
      ports:
        - 5433:5432
      environment:
        - POSTGRES_PASSWORD=XLv1SDPvOl
        - POSTGRES_USER=robocash
        - POSTGRES_DB=robocash
      networks:
        - robocash

    webserver:
      image: nginx:alpine
      container_name: robocash-webserver
      working_dir: /application
      restart: always
      volumes:
          - .:/application
          - ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
      ports:
       - "8010:80"
      networks:
        - robocash

    php-fpm:
      build: phpdocker/php-fpm
      container_name: robocash-php-fpm
      working_dir: /application
      extra_hosts:
        - "clientarea.robocash.local:172.18.0.1"
        - "admin.robocash.local:172.18.0.1"
      restart: always
      volumes:
        - .:/application
        - ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini
      networks:
        - robocash

    redis:
      image: redis:alpine
      container_name: robocash-redis
      ports:
        - 6380:6379
      networks:
        - robocash

volumes:
  postgres-volume:

networks:
  robocash:
    driver: bridge

Using auto-generated by yours container laravel-echo-server.json file.
Connecting as:

  window.Echo = new Echo({
          broadcaster: 'socket.io',
          host: window.location.hostname + ':' + '{{ env('SOCKET_PORT') }}'
      });
      window.Echo.channel('news').listen('NewsCreated', (e) => {
          console.log(e);
      });

But see nothing about success subscription on channel 'news' in logs:
image

But when invoking event, it appears in logs:
image

No errors in browser console. Seems like i have connection with sockets:
image

So, event comes to server but as i cannot subscribe to channels i cannot receive that events in browser. Could you tell me, where am i wrong?

ERR_EMPTY_RESPONSE with connection

http://localhost:6001/socket.io/?EIO=3&transport=polling&t=NkUj6jL link from network tab.

My config:

{
	"authHost": "http://localhost:8844",
	"authEndpoint": "http://localhost:8844/broadcasting/auth",
	"clients": [
		{
			"appId": "***",
			"key": "***"
		}
	],
	"database": "redis",
	"databaseConfig": {
		"redis": {
		  "port": "6379",
		  "host": "redis",
		  "keyPrefix": "laravel_database_"
		},
		"sqlite": {
			"databasePath": "/database/laravel-echo-server.sqlite"
		}
	},
	"devMode": true,
	"host": "127.0.0.1",
	"port": "6001",
	"protocol": "http",
	"socketio": {},
	"secureOptions": 67108864,
	"sslCertPath": "",
	"sslKeyPath": "",
	"sslCertChainPath": "",
	"sslPassphrase": "",
	"subscribers": {
		"http": true,
		"redis": true
	},
	"apiOriginAllow": {
		"allowCors": true,
		"allowOrigin": "http://localhost::8844",
		"allowMethods": "GET, POST",
		"allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
	}
}

And my docker compose config:

# Use root/example as user/password credentials
version: '3.1'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: php:8.0-fpm-alpine3.14
    container_name: app
    restart: always
    tty: true
    environment:
      SERVICE_NAME: app
      SERVICE_TAGS: dev
    working_dir: /var/www
    volumes:
      - ./www:/var/www
      - ./php/conf.d:/usr/local/etc/php/conf.d/
  db:
    image: mysql:8.0.26
    container_name: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_USER: example
      MYSQL_DATABASE: example
      MYSQL_PASSWORD: example
    ports:
      - 3306:3306
    volumes:
      - ./dbdata:/var/lib/mysql/
      - ./mysql:/etc/mysql/
      - ./mysql-files:/var/lib/mysql-files
  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    container_name: phpmyadmin
    restart: always
    ports:
      - 9090:80
    environment:
      - PMA_ARBITRARY=1
  redis:
    image: redis:alpine3.14
    container_name: redis
    restart: always
    volumes:
      - ./redis:/usr/local/etc/redis/
    ports:
      - 6379:6379
  echoserver:
    image: oanhnn/laravel-echo-server:latest
    container_name: laravel-echo-server
    restart: always
    ports:
      - 6001:6001
    volumes:
      - ./laravel-echo-server:/app
  webserver:
    image: nginx:alpine
    container_name: nginx
    restart: unless-stopped
    tty: true
    ports:
      - 8844:80
      - 4433:443
    volumes:
      - ./www:/var/www
      - ./nginx/conf.d/:/etc/nginx/conf.d/
volumes: 
    dbdata:
        driver: local

How to fix it?

permission denied

Hi,

I encounter this issue :

2018/10/14 22:01:22 unable to create open /app/laravel-echo-server.json: permission denied

my docker-compose file :

laravel-echo-server:
    restart: ${RESTART_MODE}
    image: oanhnn/laravel-echo-server
    container_name: laravel-echo-server
    environment:
      - APP_DEBUG=true
    volumes:
      - ${STORAGE_PATH}/exosuite-laravel-echo-server:/app
    ports:
      - "6001:6001"
    networks:
      - root-network

Thanks for reply :)

Error: connect ECONNREFUSED 127.0.0.1:80 on Laravel Sail

I try to implement docker-laravel-echo-server into Laravel Sail

services:
    app:
        build:
            context: ./docker/8.0
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
                XDEBUG: ${APP_DEBUG}
        image: sail-8.0/app
        ports:
            - '${APP_PORT:-80}:80'
        extra_hosts:
          - "host.docker.internal:host-gateway"
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
            - redis
            - selenium
    mysql:
        image: 'mysql:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        volumes:
            - 'sailmysql:/var/lib/mysql'
        networks:
            - sail
        healthcheck:
          test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
    redis:
        image: 'redis:alpine'
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sailredis:/data'
        networks:
            - sail
        healthcheck:
          test: ["CMD", "redis-cli", "ping"]
    meilisearch:
        image: 'getmeili/meilisearch:latest'
        ports:
            - '${FORWARD_MEILISEARCH_PORT:-7700}:7700'
        volumes:
            - 'sailmeilisearch:/data.ms'
        networks:
            - sail
    mailhog:
        image: 'mailhog/mailhog:latest'
        ports:
            - '${FORWARD_MAILHOG_PORT:-1025}:1025'
            - '${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025'
        networks:
            - sail
    selenium:
       image: 'selenium/standalone-chrome'
       volumes:
            - '/dev/shm:/dev/shm'
       networks:
           - sail
    laravel-echo-server:
      image: oanhnn/laravel-echo-server
      depends_on:
        - redis
      ports:
        - 6001:6001
      environment:
        LARAVEL_ECHO_SERVER_DEBUG: 'true'
      networks:
        - sail

networks:
    sail:
        driver: bridge
volumes:
    sailmysql:
        driver: local
    sailredis:
        driver: local
    sailmeilisearch:
        driver: local

Joining of public channels works fine, but if i want to join a private channel i get these error

laravel-echo-server_1  | [12:00:07 PM] - Error authenticating ScG5vjw0NJ4rNjkgAAAA for private-notify
laravel-echo-server_1  | Error: connect ECONNREFUSED 127.0.0.1:80
laravel-echo-server_1  |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
laravel-echo-server_1  |   errno: -111,
laravel-echo-server_1  |   code: 'ECONNREFUSED',
laravel-echo-server_1  |   syscall: 'connect',
laravel-echo-server_1  |   address: '127.0.0.1',
laravel-echo-server_1  |   port: 80
laravel-echo-server_1  | }

How to connect to redis server with password?

after running laravel-app and laravel-echo-server with docker-compose , service logs error redis service no auth but i set in laravel-echo-server.json file

can see this error

`L A R A V E L E C H O S E R V E R

version 1.6.2

Starting server...

✔ Running at localhost on port 6001

✔ Listening for http events...

[ioredis] Unhandled error event: ReplyError: NOAUTH Authentication required.

at parseError (/usr/local/share/.config/yarn/global/node_modules/redis-parser/lib/parser.js:179:12)

at parseType (/usr/local/share/.config/yarn/global/node_modules/redis-parser/lib/parser.js:302:14)

✔ Listening for redis events...

(node:1) UnhandledPromiseRejectionWarning: Redis could not subscribe.

(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[ioredis] Unhandled error event: ReplyError: NOAUTH Authentication required.

at parseError (/usr/local/share/.config/yarn/global/node_modules/redis-parser/lib/parser.js:179:12)

at parseType (/usr/local/share/.config/yarn/global/node_modules/redis-parser/lib/parser.js:302:14)

[ioredis] Unhandled error event: ReplyError: NOAUTH Authentication required.`

my laravel-echo-server.json file:

{
	"authHost": "127.0.0.1",
	"authEndpoint": "/broadcasting/auth",
	"clients": [
		{
			"appId": "019bd805034b881c",
			"key": "a28b503fa69a04c293c20bd8e1711120"
		}
	],
	"database": "redis",
	"databaseConfig": {
		"redis": {
            "host":"redis",
            "port":"6379",
            "password":"2ye10qwNYqzmsiNwttOVbmNk0esO0ie5TVby"
        },
		"sqlite": {
			"databasePath": "/database/laravel-echo-server.sqlite"
		}
	},
	"devMode": true,
	"host": "127.0.0.1",
	"port": "6001",
	"protocol": "http",
	"socketio": {},
	"secureOptions": 67108864,
	"sslCertPath": "",
	"sslKeyPath": "",
	"sslCertChainPath": "",
	"sslPassphrase": "",
	"subscribers": {
		"http": true,
		"redis": true
	},
	"apiOriginAllow": {
		"allowCors": false,
		"allowOrigin": "",
		"allowMethods": "",
		"allowHeaders": ""
	}
}

and my docker-compose file:

version: '3'
services:

  #PHP Service
  app-api:
    build:
      args:
        user: devups
        uid: 1000
      context: ./
      dockerfile: Dockerfile
    image: app-api
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 40m
    container_name: app-api
    restart: unless-stopped
    tty: true
    volumes:
      - ./:/var/www
      - ./docker-compose/php/local.ini:/usr/local/etc/php/conf.d/local.ini
    working_dir: /var/www
    ports:
      - "9000:9000"

    networks:
      - app-net
  #13 network_mode: "host"

  #Nginx Service
  nginx:
    image: nginx:stable-alpine
    #    depends_on:
    #      - karmento-api
    #      - db
    container_name: app-nginx
    restart: unless-stopped
    tty: true
    ports:
      - "${HTTP_PORT}:80"
      - "${HTTPS_PORT}:443"
    environment:
      - VIRTUAL_HOST=app.test # Environment variable needed for nginx proxy
    volumes:
      - ./:/var/www
      - ./docker-compose/nginx:/etc/nginx/conf.d
    expose:
      - 80
    networks:
      - app-net


  #MySQL Service
  mysql:
    image: mysql:8.0.21
    container_name: app-mysql
    restart: unless-stopped
    tty: true
    ports:
      - "3316:3306"
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_USER: ${DB_USERNAME}
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql

    volumes:
      - ./docker-compose/mysql:/docker-entrypoint-initdb.d
      - /data/mysql:/var/lib/mysql
    networks:
      - app-net
 
    #Redis
  redis:
    image: redis:rc-alpine3.11
    container_name: app-redis
    ports:
      - "6369:6379"
    volumes:
      - "/data/redis:/data"
    command: redis-server --requirepass ${REDIS_PASSWORD}
    networks:
      - app-net
  laravel-echo-server:
    image: oanhnn/laravel-echo-server
    container_name: laravel-echo
    restart: unless-stopped
    networks:
      - app-net
    ports:
      - 6001:6001
    links:
      - 'redis:redis'

 
#Docker Networks
networks:
  app-net:
    external:
      name: app-net

.
second issue when config and use in docker-compose file when set env in docker-compose file automatic restarting and faild please descrive how config and use in docker-compose file

Cannot connect to redis docker container

I have a redis container setup from bitnami/redis:latest, forwarded ports 6379 with the server up and running however, this echo server container fails to work. I get this error

L A R A V E L  E C H O  S E R V E R

version 1.5.0

Starting server...

✔  Running at 0.0.0.0 on port 6001
✔  Listening for http events...
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis redis:6379
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis redis:6379
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis redis:6379
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis redis:6379
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis redis:6379
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis redis:6379
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis redis:6379
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis redis:6379
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)

Leaves dangling lockfile if conatiner not individually stopped

I'm using Docker for Windows and the GUI to start/stop containers. I use Docker-Compose to start a bunch of containers.

If I stop the laravel-echo-server it properly removes the /app/laravel-echo-server.lock file.

However if I stop/restart Docker itself (either with the menu option, or as happens when I shut down my PC) the lock file does not get removed.

So I either need to manually stop the laravel-echo-server container or manually remove the lock file.

It'd be good if the server could ignore the lock file if it's booting (since it's a container it can't already have a server running anyway) or do whatever cleanup happens when I stop the container individually, also do that cleanup when I stop the whole of docker (assuming there's a hook available).

From a glance it looks like this issue is fixed by this PR:

https://github.com/oanhnn/docker-laravel-echo-server/pull/11/commits

Incomplete environment variable support

Hi,

Entrypoint script in /bin/docker-entrypoint has only partial support for environment variables
Only following env keys are being looked up and swapped to laravel-echo-server.json:

LARAVEL_ECHO_SERVER_DB
REDIS_HOST
REDIS_PORT
REDIS_PASSWORD
REDIS_PREFIX
REDIS_DB

Other defined environment variables have no impact.

echo does not receive messages

here is docker-compose.yml

version: '3.6'
services:
  php-fpm:
    build: docker/php-fpm
    depends_on:
      - db
      - redis
    links:
      - redis
      - db
    volumes:
      - "./:/www"
    environment:
      - DOCKER_PHP_CONFIG=${DOCKER_PHP_CONFIG}
      - DOCKER_XDEBUG=${DOCKER_XDEBUG}
      - DOCKER_SUPERVISOR=${DOCKER_SUPERVISOR}
      - DOCKER_CRON=${DOCKER_CRON}
    networks:
        - vue

  nginx:
    image: nginx:1.16-alpine
    depends_on:
      - php-fpm
    ports:
      - "8200:80"
      - "8243:443"
    volumes:
      - "./:/www"
      - "./docker/nginx/conf.d:/etc/nginx/conf.d"
    networks:
      - vue



  redis:
    image: redis
    volumes:
      - ./docker/redis:/data
    ports:
      - "8204:6379"
    networks:
      - vue

  node:
    build: docker/nodejs
    links:
      - redis
    environment:
      - REDIS_URL=redis://cache
    depends_on:
      - php-fpm
    volumes:
      - "./:/www"
    networks:
      - vue
    ports:
      - "8205:3000"
  echo:
    image: oanhnn/laravel-echo-server:latest
    depends_on:
      - redis
    environment:
      LARAVEL_ECHO_SERVER_AUTH_HOST: redis
      LARAVEL_ECHO_SERVER_DEBUG: 'true'
      LARAVEL_ECHO_SERVER_DB: redis
      REDIS_HOST: redis
      REDIS_PORT: 6379
      REDIS_DB: 0
    networks:
      - vue
    ports:
      - 8206:6001

networks:
  vue:
    driver: bridge

here is laravel-echo-server.json

{
    "apiOriginAllow": {},
    "authEndpoint": "/broadcasting/auth",
    "authHost": "http://localhost",
    "clients": [],
    "database": "LARAVEL_ECHO_SERVER_DB",
    "databaseConfig": {
        "redis": {
            "host": "REDIS_HOST",
            "port": "REDIS_PORT",
            "options": {
                "db": "REDIS_DB"
            }
        },
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        },
        "publishPresence": true
    },
    "devMode": false,
    "host": null,
    "port": 8206,
    "protocol": "http",
    "sslCertPath": "",
    "sslKeyPath": "",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "socketio": {},
    "subscribers": {"http": true, "redis": true}
}

so I connect it boorstrap.js


window._ = require('lodash');
window.Popper= require('popper.js').default;
window.io=require('socket.io-client');


window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

window.Echo = new Echo({
    broadcaster: 'socket.io',
    host:window.location.hostname+':8206',
});

vue component

<template>
    <div class="container">
        <hr/>
        <div class="row">
            <div class="col-sm-12">
                <textarea class="form-control" rows="10" readonly>{{messages.join('\n')}}</textarea>
                <hr/>
                <input type="text" class="form-control" v-model="textMessage" @keyup.enter="sendMessage">
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return {
            messages:[],
            textMessage:''
        }
    },
    mounted() {
        this.addMessage('You joined the chatbox.');
        Echo.channel('chat')
            .listen('MessageEvent',({message})=>{
                this.messages.push(message);
                console.log(message);
            })
    },
    methods:{
        addMessage(message) {
            let date= new Date();
            let timestamp = date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
            this.messages.push(timestamp + ' ' + message);
        },
        sendMessage(){
            axios.post('chat/message',
                {
                    body:this.textMessage
                }).then((response)=>{
                    this.messages.push(response.data)
                    this.textMessage="";
                });
        }
    }
}
</script>

redis-cli registers the following message

1607282947.620026 [0 172.29.0.6:49842] "EVAL" "for i = 2, #ARGV do\n  redis.call('publish', ARGV[i], ARGV[1])\nend" "0" "{\"event\":\"App\\\\Events\\\\Chat\\\\MessageEvent\",\"data\":{\"message\":\"11\",\"socket\":null},\"socket\":null}" "chat"
1607282947.620160 [0 lua] "publish" "chat" "{\"event\":\"App\\\\Events\\\\Chat\\\\MessageEvent\",\"data\":{\"message\":\"11\",\"socket\":null},\"socket\":null}"

but these messages they do not come even in debug there are only messages about connecting to the client channel

L A R A V E L  E C H O  S E R V E R

version 1.6.2

⚠ Starting server in DEV mode...

✔  Running at localhost on port 6001
✔  Channels are ready.
✔  Listening for http events...
✔  Listening for redis events...

Server ready!

[7:09:58 PM] - Qk_u__xYutZMmyqMAAAA joined channel: chat
[7:10:01 PM] - kwzT_Kk-1DVn6cQnAAAB joined channel: chat
[7:11:57 PM] - kwzT_Kk-1DVn6cQnAAAB left channel: chat (transport close)
[7:11:58 PM] - qpEoOLWSOvnU8UjaAAAC joined channel: chat
[7:12:32 PM] - Qk_u__xYutZMmyqMAAAA left channel: chat (transport close)
[7:12:33 PM] - ZSeSV4LbagHb8HieAAAD joined channel: chat
[7:12:39 PM] - ZSeSV4LbagHb8HieAAAD left channel: chat (transport close)
[7:12:40 PM] - WogY2w9Odwyh69IAAAAE joined channel: chat
[7:29:01 PM] - qpEoOLWSOvnU8UjaAAAC left channel: chat (transport close)
[7:29:03 PM] - UlNwT1oXDp9EhV00AAAG joined channel: chat

And it doesn't come to the browser either. What could be wrong ?

docker-compose.yml environment config isn't working properly

I tried to override the laravel-echo-server.json config by including some docker-compose.yml environment variables like following:

websocket:
    image: oanhnn/laravel-echo-server
    depends_on:
      - redis
      - app
    environment:
      LARAVEL_ECHO_SERVER_AUTH_HOST: http://example.com
      LARAVEL_ECHO_SERVER_DEBUG:     'true'
      LARAVEL_ECHO_SERVER_DB:        redis
      LARAVEL_ECHO_SERVER_HOST: example.com
      REDIS_HOST:     redis
      REDIS_PORT:     6379
      REDIS_PREFIX:   laravel_
      REDIS_PASSWORD: secret@123
      REDIS_DB:       0
    ports:
      - 6001:6001
    restart: unless-stopped

So I noticed that only "REDIS_*" variables are working: docker exec -it $(docker-compose ps -q websocket) cat laravel-echo-server.json

{
  "apiOriginAllow": {},
  "authEndpoint": "/broadcasting/auth",
  "authHost": "http://localhost",
  "clients": [],
  "database": "redis",
  "databaseConfig": {
    "redis": {
      "host": "redis",
      "port": "6379",
      "password": "secret@123",
      "keyPrefix": "laravel_",
      "options": {
        "db": "0"
      }
    },
    "sqlite": {
      "databasePath": "/database/laravel-echo-server.sqlite"
    },
    "publishPresence": true
  },
  "devMode": false,
  "host": null,
  "port": 6001,
  "protocol": "http",
  "sslCertPath": "",
  "sslKeyPath": "",
  "sslCertChainPath": "",
  "sslPassphrase": "",
  "socketio": {},
  "subscribers": {"http": true, "redis": true}
}

运行一会,就会中断,提示截图显示的错误

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: Command queue state error. If you can reproduce this, please report it. Last error: ERR read tcp 10.0.5.7:6379->10.0.0.3:60634: i/o timeout
    at DataHandler.shiftCommand (/usr/local/share/.config/yarn/global/node_modules/ioredis/built/DataHandler.js:164:27)
    at DataHandler.returnError (/usr/local/share/.config/yarn/global/node_modules/ioredis/built/DataHandler.js:33:27)
    at JavascriptRedisParser.returnError (/usr/local/share/.config/yarn/global/node_modules/ioredis/built/DataHandler.js:15:22)
    at JavascriptRedisParser.execute (/usr/local/share/.config/yarn/global/node_modules/redis-parser/lib/parser.js:542:14)
    at Socket.<anonymous> (/usr/local/share/.config/yarn/global/node_modules/ioredis/built/DataHandler.js:25:20)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
Emitted 'error' event on Redis instance at:
    at DataHandler.shiftCommand (/usr/local/share/.config/yarn/global/node_modules/ioredis/built/DataHandler.js:168:24)
    at DataHandler.returnError (/usr/local/share/.config/yarn/global/node_modules/ioredis/built/DataHandler.js:33:27)
    [... lines matching original stack trace ...]
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

image

配置文件:

{
  "apiOriginAllow": {
    "allowCors": true,
    "allowOrigin": "*",
    "allowMethods": "GET, POST",
    "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
  },
  "authEndpoint": "/api/admin/broadcasting/auth",
  "authHost": "http://api",
  "clients": [
    {
      "appId": "e4ad8ca7e****",
      "key": "aca3024bebc1d0978d2759****"
    }
  ],
  "database": "redis",
  "databaseConfig": {
    "redis": {
      "host": "redis-*****.jvessel-open-hb.jdcloud.com",
      "port": "6379",
      "keyPrefix": "api_ec_database_",
      "password": "*****",
      "options": {
        "db": "0"
      }
    },
    "sqlite": {
      "databasePath": "/database/laravel-echo-server.sqlite"
    },
    "publishPresence": true
  },
  "devMode": true,
  "host": "api-ws",
  "port": 6003,
  "protocol": "http",
  "sslCertPath": "",
  "sslKeyPath": "",
  "sslCertChainPath": "",
  "sslPassphrase": "",
  "socketio": {
    "path": "/op.socket.io"
  },
  "subscribers": {
    "http": true,
    "redis": false
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.