I am working on a realtime chatting application and I am using websocket with laravel
I am using library beyoundcode/laravel-websocket
I have change broadcast driver to pusher and have configured broadcaster.php to this
'connections' => [
'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'),
'host' => '127.0.0.1',
'port' => env('PUSHER_PORT', 6001),
'scheme' => env('PUSHER_SCHEME', 'http'),
'encrypted' => true,
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
When I run an event using
event(new App\Events\UserStatusEvent())
Instead of sending message to localhost which is 127.0.0.1 stated in pusher option it sends to pusher.com
I clear clear my cache and config not changes
class UserStatusEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct()
{
//
}
public function broadcastOn()
{
return new PresenceChannel('status-update');
}
}
.env
BROADCAST_DRIVER=pusher
CACHE_DRIVER=array
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
PUSHER_APP_ID=skldfjiklkd
PUSHER_APP_KEY=sdlkfewif
PUSHER_APP_SECRET=slkdfifwef
PUSHER_APP_CLUSTER=mt1
bootstrap.js
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'pusher',
key: import.meta.env.VITE_PUSHER_APP_KEY,
cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1',
wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`,
wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
});
QUEUE_CONNECTION,BROADCAST_DRIVER, and all other keys that start withPUSHER_*? Also please include theresources/js/bootstrap.jsfile in your question. P.S.laravel-websocketsby BeyondCode is no longer maintained, it's highly recommended that you refrain from using it. Instead, wait for a few days because Laravel Reverb is about to be released, so it's a better option for the current time..envfile looks legit, but is that your fullbootstrap.jsfile? I think it's missing more code from thepusher-jsclient. Regarding Laravel Reverb, Taylor Otwell said that it will be released along with Laravel 11 next Tuesday, that's 12th of March. When it gets released, I'll comment on this question to remind you.127.0.0.1:6001server. Are you using thepusherJS client directly instead of Laravel Echo ?