Search code examples
laravelpusherlaravel-echo

Laravel Echo not subscribing to pusher channel


I am not able to listen for a notification in a private channel. When I try to connect to the channel I can see in the pusher debug console that a connection is attempted but then it does not say subscribed. If I try to log the channel to the console it says subscriptionPending: true.

I am using the following code:

window.Echo.private(`App.Models.User.User.${Laravel.userId}`).notification((notification) => {
  console.log(notification);
})

I have not tried a .listen method after the .private method as I am listening for a notification to be emitted from Laravel.

Here is the contents of my channels.php file for authenticating the user

Broadcast::channel('App.Models.User.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});```

Solution

  • Turns out I was subscribing to the wrong channel, forgot my User model was in a directory called Users not User