I’ve been trying to set up my a broadcast system with pusher and followed the documentation step by step. when i start the server i get an error
"Uncaught Options object must provide a cluster"
on my console.
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => env('PUSHER_HOST', 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
so I checked my options object in the broadcast config and i noticed my config doesn’t have a cluster option so i added it manually, but still have that error.
.env
PUSHER_APP_ID=1529400
PUSHER_APP_KEY=521a8d3a78ab50e2c14d
PUSHER_APP_SECRET=ce93e12b5f74f8280624
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
e here
broadcast.php
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => env('PUSHER_HOST', 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
'cluster' => env('PUSHER_APP_CLUSTER'),
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
3
Answers
Joshua,
I ran into the same issue.
The pusher folks now make it mandatory: https://github.com/pusher/pusher-js/releases
I’m rolling my code back to previous version of pusher, hoping that works.
I encountered the same error and solved it by adding
cluster
to the parameters that are passed in the new Echo instance:bootstrap.js:
added
cluster:import.meta.env.VITE_PUSHER_APP_CLUSTER,
Also, make sure that it is added in the
broadcasting.php
in options array:EDIT
I realized that with version 8.0.0, the cluster option is mandatory. Another problem is that if you are using the Laravel-WebSockets package as a drop-in replacement for the pusher, it would be a problem because, in production, pusher connects to that cluster you provided in the options instead. So what I did is that I uninstalled pusher-js version 8.0.0 and installed pusher version 7.6 which does not require a cluster:
npm i [email protected]
do this at bootstrap.js, works great to me:
});
you can choose cluster location here:
https://pusher.com/docs/channels/miscellaneous/clusters/
at the it it doesnt matter what you put there. I am using ably.com for sockets