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

gabrielleles18's avatar

Reverb: Error joining private channel

I have a project in react native and laravel, I'm using laravel reverb to make a chat, but I'm facing some problems in the channel authentication. This is the error:

Laravel: v11.31.0 PHP: v8.2.0 Reverb: v1.0

(NOBRIDGE) LOG  Pusher :  : ["Event sent",{"event":"pusher:subscribe","data":{"channel":"private-users.1"}}]

 (NOBRIDGE) LOG  Pusher :  : ["Event recd",{"event":"pusher:error","data":{"code":4009,"message":"Connection is unauthorized"}}]

 (NOBRIDGE) WARN  Pusher :  : [{"type":"PusherError","data":{"code":4009,"message":"Connection is unauthorized"}}]

 (NOBRIDGE) LOG  Pusher connection error: {"data": {"code": 4009, "message": "Connection is unauthorized"}, "type": "PusherError"}

.env backend

REVERB_APP_ID=129771
REVERB_APP_KEY=pm4tekz01ihxkkyeuuev
REVERB_APP_SECRET=tl5uula15etq5qaviylb
REVERB_HOST="10.20.30.98"
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}"

.env frontend

REVERB_APP_ID=129771
REVERB_APP_KEY=pm4tekz01ihxkkyeuuev
REVERB_APP_SECRET=tl5uula15etq5qaviylb
REVERB_HOST="10.20.30.98"
REVERB_PORT=8080
REVERB_SCHEME=http

##Backend

resources/js/echo.js

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 ?? 80,
    wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
    forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
    enabledTransports: ['ws', 'wss'],
});

Providers/BroadcastServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;

class BroadcastServiceProvider extends ServiceProvider {
    /**
     * Bootstrap any application services.
     */
    public function boot(): void {
        Broadcast::routes([
            'prefix' => 'api/v1',
            'middleware' => ['api', 'auth:sanctum'],
        ]);

        require base_path('routes/channels.php');
    }
}

Events/MessageSent.php

routes/channels.php

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

##Frontend Echo Instance

Subscribe to chanel

The connection with the pusher seems to be working but the authentication with the channel is not, can anyone help?

1 like
3 replies
anoosss's avatar

I have the same problem and cant for the life of me understand what I'm doing wrong. Except for how im setting up window.echo my code is the same as yours.

Sajid92's avatar

same problem with me Presence & private channel is not authenticating in laravel 11 with reverb

MaverickChan's avatar

looks like need to exclude the broadcast routes from csrf verification middleware

->withMiddleware(function (Middleware $middleware) {
        $middleware->validateCsrfTokens(except: [
            '/broadcasting/auth',
        ]);
    })

i don't know if it is right, because when use another private channel, there is no error message , which also not right.

Please or to participate in this conversation.