Echo没有收到推送程序的事件

时间:2018-11-03 14:50:20

标签: laravel-5 echo pusher-js

我正在laravel中使用pusher和Echo在聊天系统上工作,我的pusher运行良好,当我触发将事件发送给pusher时,这是我的pusher调试控制台屏幕截图enter image description here

但是当我无法接收到该事件或任何可显示chrome控制台错误的内容时,我检查了此处讨论的所有错误,但还是相同的问题。请检查我的代码,并告诉我我错了。谢谢

.env文件

BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=1d583e4e42f820
MAIL_PASSWORD=aeff887f7d1784
MAIL_ENCRYPTION=null

PUSHER_APP_ID= app id(this is just for demonstration)
PUSHER_APP_KEY= my app key (this is just for demonstration)
PUSHER_APP_SECRET= app secret (this is just for demonstration)
PUSHER_APP_CLUSTER=ap2

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

回声初始化

import Echo from 'laravel-echo'

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: 'my app key',
    cluster: 'ap2',
    encrypted: true 
});

我的app.js

window.Laravel = {'csrfToken': '{{csrf_token()}}'}

   window.Echo.private('chat')
     .listen('ChatEvent', (e) => {
        console.log(e);
    });

预先感谢

0 个答案:

没有答案