SocketIO + Redis连接已关闭

时间:2018-05-24 19:51:43

标签: laravel-5 redis socket.io laravel-echo

我按照提供的文档,似乎服务器没有接受连接:

(failed)
net::ERR_CONNECTION_CLOSED
  • 我正在使用Laravel Horizo​​n,它看起来运行正常。
  • 如果我手动使用 redis-cli 命令访问服务器,并且 应用' ping'命令,我得到一个' pong'响应。

应用 laravel-echo-server start 命令后,服务器似乎已启动并运行:

L A R A V E L  E C H O  S E R V E R

version 1.3.6

⚠ Starting server in DEV mode...

✔  Running at localhost on port 6001
✔  Channels are ready.
✔  Listening for http events...
✔  Listening for redis events...

Server ready!

bootstrap.js:

import Echo from 'laravel-echo'

window.io = require('socket.io-client');

window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: window.location.hostname + ':6001',
});

.ENV:

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=redis

REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379

laravel回波-server.json

{
    "authHost": "http://dialfy.local",
    "authEndpoint": "/broadcasting/auth",
    "clients": [
        {
            "appId": "dd4d563e7e81f442",
            "key": "1627b6fd226c7f3c866ca209f78779b6"
        }
    ],
    "database": "redis",
    "databaseConfig": {
        "redis": {},
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "http",
    "socketio": {},
    "sslCertPath": "",
    "sslKeyPath": "",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "apiOriginAllow": {
        "allowCors": false,
        "allowOrigin": "",
        "allowMethods": "",
        "allowHeaders": ""
    }
}

关于问题可能是什么,或者我可以开始寻找的任何想法?我想这是一个配置问题,但我似乎无法将其放在上面。

1 个答案:

答案 0 :(得分:0)

对于遇到类似问题的其他人:原因是因为我的应用程序在本地运行https,而我没有配置laravel-echo-server来做同样的事情。