我正在为 Docker (laradock) 上的 Laravel echo 服务器设置而苦苦挣扎。我跟进了本教程。我在 docker 下设置了一个新的 laravel 项目,并将主机设置为 testing.localhost。与 Redis 的连接工作正常,回显服务器工作正常,甚至可以监听消息:
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
我的 laravel-echo-server.json 包含以下内容:
{
"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": ""
}
在客户端应用程序(Angular 应用程序)上,我尝试了几种组合:
// 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: {} };
但我总是在控制台中收到一条消息
/socket.io/?EIO=4&transport=polling&t=Nf9A_rY net::ERR_CONNECTION_REFUSED
有谁知道如何解决这个问题?