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

zlem0815's avatar

Laravel 10, Reverb & Livewire: broadcastOn event not received

I'd like to create a simple example with Laravel 10 and Reverb on my local development environment (Win 11, Xampp).

After clicking a button in my app update() and StockUpdated::dispatch() are executed. broadcastOn() should fire a public event (itemchange) and "ALERT broadcastOn!" should be added to th elog. However, the event is never recognised. All log entries (1-4) are present, but "ALERT broadcastOn!" is missing.

in app\Livewire\ListClearanceitem.php

namespace App\Livewire;

use App\Events\StockUpdated;
use App\Models\Clearanceitem;
use Livewire\Attributes\On;
use Livewire\Component;
use Illuminate\Support\Facades\Log;

class ListClearanceitem extends Component
{
    public function update($sku)
    {
        Log::info('1');
        StockUpdated::dispatch();
        Log::info('3');
    }

    public function render()
    {
        Log::info('4');        
        return view('livewire.listclearanceitems.index')->with([
            'clearanceitems' => Clearanceitem::all(),
        ]);
    }

    #[On('echo:itemchange,StockUpdated')]
    public function alert()
    {
        Log::info('ALERT broadcastOn!');
    }
}

app\Events\StockUpdated.php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;

class StockUpdated implements ShouldBroadcast
//also tried class StockUpdated implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public function broadcastOn() 
    {        
        Log::info('2');
        return new Channel('itemchange');
    }
}

resources\js\bootstrap.js

import _ from 'lodash';
window._ = _;

import axios from 'axios';
window.axios = axios;

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

import Echo from 'laravel-echo';
 
import Pusher from 'pusher-js';
window.Pusher = Pusher;
 
window.Echo = new Echo({
    broadcaster: 'reverb',
    key: import.meta.env.VITE_REVERB_APP_KEY,
    wsHost: import.meta.env.VITE_REVERB_HOST,
    wsPort: import.meta.env.VITE_REVERB_PORT,
    wssPort: import.meta.env.VITE_REVERB_PORT,
    forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
    enabledTransports: ['ws', 'wss'],
});

php artisan reverb:start --debug shows that an ‘itemchange’ event is being waited for

{  
  "event": "pusher:subscribe", 
      "data": { 
    	    "auth": "", 
 	    "channel": "itemchange"
	}
}

App\Providers\BroadcastServiceProvider::class in config\app.php is uncommented

I have also tried different settings in .env and httpd-vhosts.conf, but nothing has worked so far

in .env

...
APP_URL=http:// my.localhost /

QUEUE_CONNECTION=sync
BROADCAST_CONNECTION=reverb

REVERB_APP_ID=###
REVERB_APP_KEY=###
REVERB_APP_SECRET=###
REVERB_HOST=127.0.0.1
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}"
...

C:\xampp\apache\conf\extra\httpd-vhosts.conf

<VirtualHost *:80>
    ServerName my.localhost
    DocumentRoot "\xampp\htdocs\my_test\public"    
    
    <Directory "\xampp\htdocs\my_test\public">
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
    </Directory>    
</VirtualHost>

0 likes
1 reply
Mister_JS's avatar

hello, bro. Have you already run these commands?

php artisan queue:listen

or

php artisan queue:work

Please or to participate in this conversation.