我正在使用 redis 和 laravel-echo-server 进行广播。
当我在 bootstrap.js 中初始化Echo时,例如:
import Echo from 'laravel-echo';
window.io = require('socket.io-client');
if (typeof io !== 'undefined') {
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001',
})
}
我在控制台中收到错误:
app.js:12063 POST http://app.blog:6001/socket.io/?EIO=4&transport=polling&t=NMmu7VC 400 (Bad Request)
当我单击它时显示:
{
code: 2
message: "Bad handshake method"
}
laravel-echo-server.json
{
"appKey": "base64:HfA91lrA3RDCklIxjodAFREue6lmhA1oslXYMVTceR8=",
"authHost": "app.blog",
"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": ""
}
}
尽管出现错误,事件广播仍能正常工作,但我想使用广播通知
答案 0 :(得分:2)