laravelbroadcastinglaravel-11

Laravel 11 - Private channel authorization failing after upgrade from Laravel 10


I recently upgraded my application from Laravel 10 to Laravel 11 using Laravel Shift. After the upgrade, I noticed that my private channels with Pusher are no longer authenticating. The error logs in Pusher's console are filled with "Auth info required to subscribe to private-users.2".

In Laravel 11's documentation, they omitted the bit about using an authorizer() function when setting up the Laravel Echo instance. I'm unsure if this is related, but I left it in for now. I confirmed that the call to "broadcasting/auth" is reaching the "Illuminate\Broadcasting › BroadcastController@authenticate" controller. However, the request never seems to reach the channel authorization callback. It returns an empty 200 response.

In my channels.php, I've set the channel as follows:

Broadcast::channel('users.{id}', UsersChannel::class);

Here's the UsersChannel:

<?php

namespace App\Broadcasting;

use App\Models\User;

class UsersChannel
{
    public function __construct()
    {
        //
    }

    public function join(User $user, int $id): array|bool
    {
        return (int) $user->id === (int) $id;
    }
}

I can see the channel listed when using the command "php artisan channel:list". I'm wondering if there's an implicit change in Laravel 11 that I'm overlooking.

I've confirmed that channels.php is present in the new bootstrap\app.php. I also ran the "php artisan install:broadcasting" command, so everything should be correctly registered after the update.


Solution

  • Solution found.

    One of the changes in Laravel 11 included updating the environment variable for the default broadcast provider. The environment variable "BROADCAST_DRIVER" was changed to "BROADCAST_CONNECTION".

    After updating that name everything worked as it did before.