我试图在laravel5.1 Web应用程序中实现套接字连接 我的Web应用程序在Docker容器中运行。
我已经使用kylestev/laravel-echo-server
设置了laravel-echo-server,并且按预期运行
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',
});
}
window.Echo.channel('test-event')
.listen('Eventname', (e) => {
console.log(e);
});
当我在浏览器中加载页面时,轮询请求失败,并出现EMPTY_RESPONSE错误。
{
"authHost": null,
"authEndpoint": null,
"database": "redis",
"databaseConfig": {
"redis": {
"port": "6379",
"host": "redis"
},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": "hms.zuzurooms.local",
"port": "6001",
"protocol": "http",
"socketio": {},
"sslCertPath": "",
"sslKeyPath": "",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
"http": true,
"redis": true
},
"apiOriginAllow": {
"allowCors": false,
"allowOrigin": "",
"allowMethods": "",
"allowHeaders": ""
}
}