Laravel回显身份验证问题

时间:2018-08-03 14:58:20

标签: php laravel websocket socket.io laravel-echo

我的服务器似乎运行正常,但是当我尝试使用通道时,遇到了身份验证问题,似乎无法解决!我尝试了谷歌搜索,并在这里/其他论坛上没有运气。当前代码如下,如果我错过了任何重要的事情,请告诉我

  

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

     

版本1.3.6

     

⚠以DEV模式启动服务器...

     

✔在端口6001的本地主机上运行✔通道已就绪。 ✔   监听http事件...✔监听redis事件...

     

服务器就绪!

运行homepage.js中的代码时出现以下错误:

  

客户端无法通过身份验证,HTTP状态为403⚠[14:48:06]-   Lj8a6VF8LJ4WwvL6AAAD无法通过身份验证   present-mychannel.117

bootstrap.js

import Echo from "laravel-echo"
window.io = require('socket.io-client');
// Have this in case you stop running your laravel echo server
if (typeof io !== 'undefined') {
    window.Echo = new Echo({
        broadcaster: 'socket.io',
        host: window.location.hostname + ':6001'
    });
}

laravel-echo-server.json

{
"authHost": "myapp.laravel",
"authEndpoint": "/broadcasting/auth",
"clients": [
    {
        "appId": "HASHhere",
        "key": "KeyHere"
    }
],
"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": true,
    "allowOrigin": "myapp.laravel:80",
    "allowMethods": "GET, POST",
    "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
}
}

homepage.js

 Echo.join('mychannel.' + 117)
        .here((users) => {
            console.log("i am here");
        })
        .joining((user) => {
            console.log("joining");
        })
        .leaving((user) => {
            console.log("leaving");
        });

MessagePushed.php

 public function broadcastOn()
{
    return new PresenceChannel('mychannel.' . auth()->user()->id);
}

任何帮助/指针将不胜感激,因为我似乎无法弄清楚我要去哪里错了!

0 个答案:

没有答案