在同一域上的https和socket.io.js位置上的Laravel 5.5 laravel-echo-server.json配置

时间:2019-02-06 09:46:10

标签: laravel-5

我的整个laravel-echo-server.json如下所示

{
    "authHost": "https://example.com",
    "authEndpoint": "/broadcasting/auth",
    "clients": [
        {
            "appId": "created using command laravel-echo-server init",
            "key": "created using command laravel-echo-server init"
        }
    ],
    "database": "redis",
    "databaseConfig": {
        "redis": {
        "host": "example.com ip address",
        "port": 6379
       },
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "https",
    "socketio": {},
    "sslCertPath": "/home/username/ssl/certs/XXX..XX.crt",
    "sslKeyPath": "/home/username/ssl/keys/XXX...XX.key",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "subscribers": {
        "http": true,
        "redis": true
    },
    "apiOriginAllow": {
        "allowCors": false,
        "allowOrigin": "",
        "allowMethods": "",
        "allowHeaders": ""
    }
}

“ public / js / app.js”中的代码段:

window.Echo = new __WEBPACK_IMPORTED_MODULE_0_laravel_echo__["a" /* default */]({
    broadcaster: 'socket.io',
    host: window.location.hostname + ':6001'
});

laravel-echo-server启动和redis-cli监视器也可以正常工作。

但是在浏览器(检查元素)中,http://example.com:6001/socket.io/?EIO=3&transport=polling&t=MZ29tzO不返回任何响应。

服务器:Cent OS 7

1 个答案:

答案 0 :(得分:0)

请确保:

  • 您已经安装了npm install --save socket.io-clientnpm install --save laravel-echo
  • 端口6001已打开

我一直关注this instructions and customized some configurations。看看my laravel-echo-server.json working on LOCAL enviromentthis laravel-echo-server.json working on PRODUCTION enviroment,它应该可以为您提供见识。