will83's avatar
Level 1

Broadcasts not working

My broadcasts worked fine yesterday. I don't think anything changed, but now they don't work.

I have installed reverb, and with the server running in debug mode, I can see that events are fired to both my channels (private-users.1 and public-notifications).

I have the broadcasts running via a notification. The notification gets logged to the database. When implementing logging, I can also see that all the broadcast functions are being run.

I have my queues running, and I can see that the notification runs. The only difference I see today is that "Illuminate\Notifications\Events\BroadcastNotificationCreated" shows up in my queue as well. I don't know why that is now showing up, but it seems like that is causing the issue.

I've also changed my broadcastdriver to "log" and can see the notification in my logs at that time.

Any thoughts?

Here is my set-up: Echo.js

Channels route file

use Illuminate\Support\Facades\Broadcast;

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

Broadcast::channel('public-updates', function () {
    return true;
});

.env

BROADCAST_DRIVER=reverb
REVERB_APP_ID=idhere
REVERB_APP_KEY=keyhere
REVERB_APP_SECRET=secrethere
REVERB_HOST="localhost"
REVERB_PORT=8080
REVERB_SCHEME=http

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"

Notification

0 likes
2 replies
will83's avatar
Level 1

When I create a broadcast event, everything works fine. When I broadcast via an event, it does not work. The below works:

will83's avatar
Level 1

Solution: To listen for broadcasts I had to use the following:

window.Echo.channel(`public-updates`)
        .listen('.user.notification', (e) => {
            console.log('public update');
        })
        .notification((notification) => {
            console.log(notification.type);
        });

Please or to participate in this conversation.