1 year ago

Laravel event is not broadcasting on production server

Posted 1 year ago by tanmay_das

I am using laravel-websockets package for some real-time features. I am using redis as queue connection. I have an event TestUpdated which I am broadcasting on test.{id} private channel. The event gets fired and caught by the client properly when I am on a local machine. But on production server, I get BroadcastException thrown:

Illuminate\Broadcasting\BroadcastException in /home/forge/mydomain.com/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:117

Horizon dashboard also exposes the event data:

event: {
test: {
class: "App\Test",
id: 1,
relations: [
connection: "mysql"
socket: null
connection: null,
queue: null,
chainConnection: null,
chainQueue: null,
delay: null,
chained: [

Fragment of my websockets.php config file:

'apps' => [
        'id' => env('PUSHER_APP_ID'),
        'name' => env('APP_NAME'),
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'enable_client_messages' => true,
        'enable_statistics' => false,

My observations:

  • Pusher gets connected. authEndpoint hits properly. I
  • Presence channel works.
  • The noticable difference between local machine and production is that on production the scheme is https

I am using an arbitrary pusher app id, key and secret (someId, someKey and someSecret'). My client-side config:

window.Echo = new Echo({
    authEndpoint: 'my/endpoint',
    broadcaster: 'pusher',
    key: 'someKey',
    wsHost: process.env.NODE_ENV == 'development' ? window.location.hostname : 'mydomain.com',
    wsPort: 6001,
    wssPort: 6001,
    disableStats: true,
    encrypted: process.env.NODE_ENV == 'development' ? false : true

Config from broadcasting.php:

'pusher' => [
        'driver' => 'pusher',
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'app_id' => env('PUSHER_APP_ID'),
        'options' => [
            'cluster' => env('PUSHER_APP_CLUSTER'),
            'encrypted' => true,
            'host' => '',
            'port' => 6001,
            'scheme' => env('PUSHER_SCHEME')

How do I fix this?

Please sign in or create an account to participate in this conversation.