laravel-websockets
laravel-websockets copied to clipboard
Laravel-websockets not working over HTTPS (Laragon Apache - Localhost)
Laravel-Websockets not working over HTTPS
on Laragon (Apache)
Currently I'm using the default Laragon generated SSL certificate, I'm not sure how to add the SSL certificates with my Websocket.
My project directory: E:\Websites\laravel\ComputerReflex
My SSL Directory: E:\laragon\etc\ssl
On the documention it's mentioned to add the SSL certificate path on .env
file, which I've tried but after doing that the websockets even stops working over HTTP
LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT=E:\laragon\etc\ssl\laragon.crt
LARAVEL_WEBSOCKETS_SSL_LOCAL_PK=E:\laragon\etc\ssl\laragon.key
// config/broadcasting.php
'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'),
'encrypted' => true,
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'https' // Tried http -> https
],
],
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
wsHost: window.location.hostname, // Returns 'computerreflex.test'
wsPort: 6001,
wssPort: 6001,
disableStats: true,
forceTLS: true,
enabledTransports: ['ws', 'wss']
});
Hello,
try adding this to the broadcasting.php:
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'encrypted' => true,
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'https',
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
]
],
In websockets.php, add this in the ssl array:
'verify_peer' => false,
'allow_self_signed' => true,
And use this Echo config:
window.Echo = new Echo({
broadcaster: 'pusher',
key: '{{env("PUSHER_APP_KEY")}}',
cluster: '{{env("PUSHER_APP_CLUSTER")}}',
forceTLS: true,
disableStats: false,
wsHost: window.location.hostname,
wssPort: 6001
});
Having the same problem over localhost on my Mac.
This was previously working. All my options are as suggested above.
I'm using Laravel Valet to create the SSL certificate.
Was working fine for months, now all of a sudden nothing works