A few notes on the implementation of laravel-websocket from local to deployment. A reminder to myself that this package will replace pusher and will have my own “pusher” service.
Here are the gists:
- On the “`.env“` file the line “`MIX_PUSHER_APP_PORT=6001“` can be port 443 if you are using this proxy configuration on your server (https://docs.beyondco.de/laravel-websockets/1.0/basic-usage/ssl.html#usage-with-a-reverse-proxy-like-nginx)
- On the broadcasting.php file
Make sure to follow the config stated on the docs especially the options part. DON’T configure SSL on the backend configuration because nginx will handle the encrypted connection. The backend will proxy it to http://127.0.0.1:6001
... '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_APP_PORT', 6001), 'scheme' => 'http' ], ], ...
- On the websockets.php
Change config to use env config to be more flexible
- On the echo.js file
- Set encrypted to true because we are connecting through https.
... encrypted: true, ...
- Set the enabledTransports so that it won’t connect to pusher.com’s service. A 3rd party service.
... enabledTransports: ['ws', 'wss'], ...