Hey there, I'm having a bug in my Laravel code with Reverb.
As I try to send a notification with websockets - my logs are telling me my app keys aren't in the cluster. My frontend does connect with my websocket and I get a heartbeat on it. I also run:
php artisan queue:work and php artisan reverb:start. The exact error looks like this:
. {"exception":"[object] (Illuminate\\Broadcasting\\BroadcastException(code: 0): Pusher error: App key <redacted> not in this cluster. Did you forget to specify the cluster?```
My .env looks like this:
BROADCAST_CONNECTION=reverb
...
REVERB_APP_ID=<app_id_genned_by_reverb>
REVERB_APP_KEY=<app_key_genned_by_reverb>
REVERB_APP_SECRET=<app_secret_genned_by_reverb>
REVERB_HOST=<domain_without_scheme>
REVERB_PORT=8080
REVERB_SCHEME=http
VITE_APP_ENV="${APP_ENV}"
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST=<domain_without_scheme>
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
I wonder if it'll help any - but this is the code that should fire the broadcast event:
```php
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\BroadcastMessage;
use App\Models\Flight;
use App\Models\User;
class FlightMarkedForReview extends Notification implements ShouldQueue
{
use Queueable;
protected $flight;
protected $markedBy;
/**
* Create a new notification instance.
*/
public function __construct(Flight $flight, User $markedBy)
{
$this->flight = $flight;
$this->markedBy = $markedBy;
}
/**
* Get the notification's delivery channels.
*/
public function via($notifiable)
{
return ['database', 'broadcast'];
}
/**
* Get the array representation of the notification (for database storage).
*/
public function toArray($notifiable)
{
return [
'flight_id' => $this->flight->id,
'marked_by_id' => $this->markedBy->id,
'marked_by_name' => $this->markedBy->name,
'message_key' => 'notifications.flight_marked_for_review',
'message_params' => [
'id' => $this->flight->id,
'name' => $this->markedBy->name,
],
'message' => "Flight #{$this->flight->id} has been marked for review by {$this->markedBy->name}",
];
}
}