PusherBroadcaster.php中的Laravel 5.5 BroadcastException(第106行)

时间:2017-09-22 09:02:53

标签: javascript laravel laravel-5 vue.js pusher

我不知道为什么我得到 BroadcastException 在PusherBroadcaster.php(第106行)我正在使用Laravel 5.5和Vue 2.0。我已经尝试了一切可能但没有运气。急需帮助。我做了:

.ENV

PUSHER_APP_ID=403348
PUSHER_APP_KEY=691857f3d69337b25cf9
PUSHER_APP_SECRET=f36dc5c5114067449338

broadcasting.php

'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => 'us2',
                'encrypted' => true
            ],
        ],

bootstrap.js

import Vue from 'vue';
import VueRouter from 'vue-router';
import VueAutosize from 'vue-autosize';
import axios from 'axios';
import Form from './utilities/Form';
import Echo from "laravel-echo";
import Pusher from 'pusher-js';


window.Vue = Vue;


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

Vue.use(VueRouter);
Vue.use(VueAutosize)

window.axios = axios;
window.axios.defaults.headers.common = {
    'X-Requested-With': 'XMLHttpRequest'
};

window.Form = Form;

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: '691857f3d69337b25cf9',
    cluster: 'us2',
    encrypted: true,
});

NotificationEvent.php

class NotificationEvent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public function broadcastOn()
    {
        return new Channel('notifications');
    }
}

app.js

import './bootstrap';
import router from './routes'; 

new Vue({
    el: '#app',
    router,

    created() {
        Echo.channel('notifications')
            .listen('NotificationEvent', (e) => {
                alert('adada');
            });
    }
});

web.php

Route::get('notification', function() {
    event(new NotificationEvent());
});

尝试 / notification

时显示

enter image description here

提前致谢..

1 个答案:

答案 0 :(得分:0)

推杆需要SSL才能工作。在您的Broadcasting.php中将经过加密的=> false放入本地开发,然后尝试。为我工作...