Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Veur's avatar
Level 2

Broadcasted Notifications are completed in Horizon, but not handled by Reverb

I've installed and configured Laravel Reverb & Echo. It all works fine with Laravel Events that implement ShouldBroadcastNow, and with traditional Laravel notification classes that use sync as the connection:

    public function toBroadcast(object $notifiable): BroadcastMessage
    {
        $data = [
            'order_id' => $this->order->id,
            'amount' => 123,
        ];
        
        return (new BroadcastMessage($data))->onConnection('sync');
    }

But when I use ShouldBroadcast instead of ShouldBroadcastNow in the Event, or remove the ->onConnection('sync'); part from the Notification, it doesn't work anymore.

The jobs BroadcastNotificationCreated are succesfuly handled by the queue, but nothing happens in Reverb (which I check using php artisan reverb:start --debug). While I'm subscribed to the channel:

Message Received ............................................................................................................. 634877862.511807337

   1▕ {
   2▕     "event": "pusher:subscribe",
   3▕     "data": {
   4▕         "auth": "sgu7kglqvanjdymzkagp:a61791396adc789f0954bf8b029e9b894165915f32721b0b48c56ecb011aba3a",
   5▕         "channel": "private-users.1"
   6▕     }
   7▕ }

  Message Handled .............................................................................................................. 634877862.511807337

Any suggestions?

0 likes
2 replies
Snapey's avatar

In the job, are you referencing the request or the current user? IE something that is not available when the job is processed by a queue worker?

Veur's avatar
Level 2

@Snapey there is no job, or do you mean the Notification when it's queued? In there I'm not referencing the request/user. There are no errors in Horizon, the job gets completed (see output below).

Here are the steps I take:

The Notification is sent using: $user->notify(new OrderCreatedNotification($order));

This is the content of the OrderCreatedNotification class:

class OrderCreatedNotification extends Notification implements ShouldBroadcast
{
    use Queueable;
    
    public function __construct(
        public Order $order,
    ) {}

    public function via($notifiable): array
    {
        return ['broadcast', 'mail'];
    }

    public function toMail($notifiable): MailMessage
    {
        // Returns the mail, which I'm receiving.
    }

    public function toBroadcast(object $notifiable): BroadcastMessage
    {
        return new BroadcastMessage([
            'order_id' => $this->order->id,
            'amount' => $this->order->amount,
        ]);
    }
}

Horizon output of Illuminate\Notifications\Events\BroadcastNotificationCreated:

{
  "event": {
    "notifiable": {
      "class": "App\Domains\Users\Models\User",
      "id": 1,
      "relations": [
      ],
      "connection": "mysql",
      "collectionClass": null
    },
    "notification": {
      "order": {
        "class": "App\Domains\Billing\Models\Order",
        "id": 1,
        "relations": [
        ],
        "connection": "mysql",
        "collectionClass": null
      },
      "id": "9cf6798e-d048-4a2b-91fe-8f357327ad16"
    },
    "data": {
      "order_id": 1,
      "amount": 123
    }
  },
  "tries": null,
  "timeout": null,
  "backoff": null,
  "maxExceptions": null,
  "connection": null,
  "queue": null,
  "chainConnection": null,
  "chainQueue": null,
  "chainCatchCallbacks": null,
  "delay": null,
  "afterCommit": null,
  "middleware": [
  ],
  "chained": [
  ]
}

Please or to participate in this conversation.