Closed stesvis closed 2 years ago
UPDATE
It works if I trigger a public Channel
but not with a PrivateChannel
.
What is the correct way to subscribe to a private channel?
The process for authenticating for a private channel in Laravel is unique and can be found at https://laravel.com/docs/9.x/broadcasting#authorizing-channels.
To subscribe to a private channel in the client you need to prefix the channel name private-
, for example private- login-notification.${currentUser?.id}
. You will also need to provide an auth endpoint. It appears you are using PusherJS, so you can find info on this setting at https://github.com/pusher/pusher-js#channelauthorization-object
I haven't had a response to this one so I will close it out - if you need further assistance it may be best to get in touch with us at https://support.pusher.com/hc/en-us/requests/new
I set up Pusher in my frontend (React) app, and I am able to receive all the events I subscribe to, but ONLY when I send them from the Pusher Debug console.
The problem is when I try to trigger the same event from my Laravel 9 backend. In this case I never receive it in React.
Let me paste some code.
LoginNotificationEvent.php
:channels.php
:broadcasting.php
:Route that fires the event:
React code:
When I execute the
/test
route from Postman I can see the number of total messages increase every time in the Pusher console, but I do not receive them in React: https://snipboard.io/OzVwU8.jpgI made sure that all the Pusher variables match between Laravel and React, so I really don't know what I am doing wrong, in either side... Any missing code? Wrong configuration?
Thanks!