简体   繁体   中英

Laravel echo-server socket.io connection refused on docker

I'm struggling with a setup for Laravel echo server on Docker (laradock). I followed up this tutorial . I setup a new laravel project under docker, and setup host to be testing.localhost. Connection with Redis works fine, echo server works fine and even listen for messages:

    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!

Channel: user-channel
Event: UserEvent

My laravel-echo-server.json contains this:

{
    "authHost": "localhost",
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
        "redis": {
            "port": "6379",
            "host": "redis"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "http",
    "socketio": {},
    "sslCertPath": "",
    "sslKeyPath": ""
}

On client app (Angular application), I tried a several combination:

// const config: SocketIoConfig = { url: '10.0.75.1:6001', options: {} }; - docker IP address
// const config: SocketIoConfig = { url: '192.168.1.7:6001', options: {} }; - my IP address
// const config: SocketIoConfig = { url: 'localhost:6001', options: {} };
// const config: SocketIoConfig = { url: '127.0.0.1:6001', options: {} };

But I always get a message in console

/socket.io/?EIO=4&transport=polling&t=Nf9A_rY net::ERR_CONNECTION_REFUSED

Does anyone know how to solve this problem?

Add to host laravel echo 0.0.0.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM