Skip to content
Advertisement

Pusher Doesn’t Broadcast on Private Channels -PHP/Laravel

I have set up Pusher and Laravel Echo for my app to notify users on some event firings.

I have tested to see whether setup is working by broadcasting on a “Public Channel” and successfully saw that is works.

Here is the event itself:

JavaScript

Public channel:

JavaScript

app/resources/assets/js/bootstrap.js:

JavaScript

And Laravel Echo registration: (it is in the “head” section of my main layout that event firing view extends from.)

JavaScript

Now, this setup works for public channel broadcasting, but when i try to broadcast on a private channel, i get

JavaScript

JavaScript

I have checked the outgoing network requests from developer console and find out pusher is trying to “POST” to

JavaScript

but it gets a 500 error code.

Thought that might help figure out the problem.

What should i do ?

Advertisement

Answer

So i figured out how should i implement private channel listening and got it working.

My mistake was in wildcard choice.

I was telling it to use the authenticated user id as a wildcard instead of item id that changes are applied to.

Therefore, this below channel registration was always returning false and was causing Pusher to throw 500 auth couldn’t found.

JavaScript

So, here is the working version:

Event being broadcasted:

JavaScript

Channel registration:

JavaScript

Laravel Echo registration:

JavaScript

Thank you all for pointers.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement