Laravel Echo not receiving Pusher event
Asked Answered
A

1

6

I am having trouble with Laravel Echo to listener to Pusher channels. I am not able to get any response in my browser (no console log).

In my bootstrap.js I got.

import Echo from "laravel-echo"

window.Echo = new Echo({
     broadcaster: 'pusher',
     key: 'myPusherAppKey',
     cluster: 'mt1', //My app is US-EAST
     encrypted: true
});

I use my browser console and type:

Echo.channel('my-channel')
    .listen('my-event', (e) => {
        console.log(e);
    });

I can see from the Pusher Debug Console that

  1. CONNECTION My app
  2. SUBSCRIBED My-channel
  3. OCCUPIED My-channel

I then use the Pusher Debug Console to send the default event:

Channel: my-channel 
Event: my-event
Data: {
       "name": "John",
       "message": "Hello"
       }

However, I do not get any output in my browser console.

If I further type in my browser console:

Echo.leave('my-channel');

I can see from Pusher Debug Console

  1. UNSUBSCRIBED my-channel
  2. VACATED my-channel

How can I get Laravel Echo to listen to Pusher events?

Acalia answered 26/12, 2016 at 22:57 Comment(0)
A
17

It was a Namespace issue. Laravel documentation explains it.

Echo will automatically assume the events are located in the App\Events namespace

Therefore, the event name must be changed in the Pusher Debug Console as such:

Event: App\Events\my-event
Acalia answered 26/12, 2016 at 23:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.