rap-2-h rap-2-h - 9 months ago 89
PHP Question

Event broadcating: Laravel Echo fails receiving broadcasts

I can make the front part of laravel Echo work with pusher. In my


import Echo from "laravel-echo"

window.Echo = new Echo({
broadcaster: 'pusher',
key: 'MY_KEY', // I use my own key.
cluster: 'eu',
encrypted: true

Then, I build my JS with
(everything is alright). Then I run a random page of my local website (using Valet), open the web console and type:

Echo.channel('survey').listen('survey', function(e) { console.log('test'); });

Then I connect to pusher and send an event.

pusher interface

And nothing appends on my local website. No alert, no error or warning in my console, nothing I can see. Here is the debug return from pusher:

enter image description here

I don't know what to do to make it work, I think I've carefully read the documentation, but maybe I missed something.

Answer Source

if you are sending events through pushers console you need to set the full namespace of the event. For example App/Events/survey. Echo adds the namespace automatically for you.

Have a look at https://laravel.com/docs/5.3/broadcasting#receiving-broadcasts under namespaces.

If you would send the event from Laravel it would use the complete namespace.