Databse notifications with echo, websocket doesnt receive messages

I set up the database notifications with pusher, the event sends a message successfully to pusher, only the front-end doesnt seem to be receiving these messages, could it be that im missing something?
42 Replies
toeknee
toeknee2y ago
Do they ever receive them, so on page refresh?
Welzh
WelzhOP2y ago
I dont think so, so far I only get the connection message
No description
Welzh
WelzhOP2y ago
In pusher I do get the message sent by the event
No description
toeknee
toeknee2y ago
I'm not familiar with pusher, are you using filamentNotifications? if so have you setup the notifications icon and livewire call
Welzh
WelzhOP2y ago
Yes I have, I do get the notifications but only with the polling functionality
Welzh
WelzhOP2y ago
No description
toeknee
toeknee2y ago
Ok so they are storing correctly, I am a little unsure how you would handle the websocket behaviour to be honest, one of the other guys may have a better solution
Welzh
WelzhOP2y ago
Alright, thanks for trying 😄
toeknee
toeknee2y ago
No problem
Dan Harrin
Dan Harrin2y ago
did you dispatch the event? cant remember what its called
Welzh
WelzhOP2y ago
No description
Welzh
WelzhOP2y ago
Yeah its dispatching it correctly
Dan Harrin
Dan Harrin2y ago
did you set up a private broadcasting channel? in channels.php
Welzh
WelzhOP2y ago
Hmm, that I have not ! It does have this one already set up in the project:
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
That should be correct right? seeing that in pusher it uses channel private-App.Models.User.3
Dan Harrin
Dan Harrin2y ago
lets simplify add to User.php
public function receivesBroadcastNotificationsOn(): string
{
return "users.{$this->getKey()}";
}
public function receivesBroadcastNotificationsOn(): string
{
return "users.{$this->getKey()}";
}
in channels.php
Broadcast::channel('users.{userKey}', function (User $user, string $userKey): bool {
return $user->is(User::find($userKey));
});
Broadcast::channel('users.{userKey}', function (User $user, string $userKey): bool {
return $user->is(User::find($userKey));
});
Welzh
WelzhOP2y ago
Again the same, it sends it sucessfully to pusher, with the new channel, only the f/e doesnt receive the message strange
Dan Harrin
Dan Harrin2y ago
can you debug in the pusher dashboard? you could send a screenshot of that
Welzh
WelzhOP2y ago
this is what I can see in pusher
No description
Dan Harrin
Dan Harrin2y ago
so theres a connection but the channel is not subscribed? because there should be a Subscription event there can you show me how you've set up Laravel Echo in your JS?
Welzh
WelzhOP2y ago
No description
Welzh
WelzhOP2y ago
Yeah seems like its not subscribing but it is connecting
Dan Harrin
Dan Harrin2y ago
can you see window.addEventListener('EchoLoaded', () => { anywhere in your generated HTML?
Welzh
WelzhOP2y ago
found this in the source
Welzh
WelzhOP2y ago
No description
Welzh
WelzhOP2y ago
(im logged in as user 2 rn, instead of user 3 when I sent the pusher screenshot)
Dan Harrin
Dan Harrin2y ago
maybe that isnt being executed? can you try sending that window.dispatchEvent line from the JS console
Welzh
WelzhOP2y ago
hmm
Welzh
WelzhOP2y ago
No description
Dan Harrin
Dan Harrin2y ago
do you have the pusher php sdk installed
Welzh
WelzhOP2y ago
Yeah thats installed!
Dan Harrin
Dan Harrin2y ago
why isnt that route set up? 🤔
Dan Harrin
Dan Harrin2y ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Welzh
WelzhOP2y ago
Added them, they give a 403 though
Dan Harrin
Dan Harrin2y ago
is your Broadcast::channel callback being hit? it's very likely that either that is returning false, or Pusher is not properly installed in PHP. I also hit that before
Welzh
WelzhOP2y ago
No description
Welzh
WelzhOP2y ago
yeah nothing is happening in here
Dan Harrin
Dan Harrin2y ago
okay well you can debug inside the laravel core as to why this isnt being executed please double check pusher is set up correctly in php
Welzh
WelzhOP2y ago
I will check, do you have any resources / tips on how to? 😊
Dan Harrin
Dan Harrin2y ago
not really track the code execution path i guess
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Welzh
WelzhOP2y ago
Hi yes I had it enabled! thanks well, it does work on production, so I guess ill leave it like this 😆
Dan Harrin
Dan Harrin2y ago
weird lol
Want results from more Discord servers?
Add your server