创建事件并将其发送到 Redis 后,我尝试订阅该事件并通过 Vue 组件中的 socket.io 向 laravel-echo-server 发出请求。
window.Echo.channel('chat')
.listen('Message', ({message}) => {
this.messages.push(message);
});
我用命令启动了 laravel-echo-server
laravel-echo-server start
{
"authHost": "http://localhost",
"authEndpoint": "/broadcasting/auth",
"clients": [],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "http",
"socketio": {},
"secureOptions": 67108864,
"sslCertPath": "",
"sslKeyPath": "",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
"http": true,
"redis": true
},
"apiOriginAllow": {
"allowCors": false,
"allowOrigin": "",
"allowMethods": "",
"allowHeaders": ""
}
}
另外,我开始排队。
php artisan queue:work
和 Laravel 开发服务器。
php artisan serve
提交表单后,redis-monitor 显示事件已生成并到达 Redis 服务器,但我在 Firefox 浏览器中得到响应。
http://127.0.0.1:6001/socket.io/?EIO=4&transport=polling&t=NXbeHKa
96:0{"sid":"tmJyofZrnWNMGxIqAALI","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":5000}2:40
并且消息不会发送给订阅的客户
我怎样才能解决这个问题?