0

I have server where I serve Laravel app from sub-directory like https://laravel-apps.test/app1. It throws this error WebSocket connection to 'wss://laravel-apps.test:6001/app/Kfjaina1m7?protocol=7&client=js&version=7.0.3&flash=false' failed:.

It works if I serve the app directly like https://laravel-app1.test. I'm sure I'm missing something but I'm not figuring out what? Probably the above URL should also contain the sub-directory string when making connect but I don't know how can I change that.

Any help will greatly appreciated, thank you! :)

app.js

window.Echo = new Echo({
  broadcaster: 'pusher',
  key: process.env.MIX_PUSHER_APP_KEY,
  wsHost: window.location.hostname,
  wsPort: 6001,
  wssPort: 6001,
  forceTLS: true,
  disableStats: true,
});

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'),
    'host' => '127.0.0.1',
    'encrypted' => false,
    'port' => 6001,
    'scheme' => env('HTTP_SCHEME', 'http')
  ]
],

1 Answers1

0

Well in secure context you must use https schema in broadcast.php and also add a certificate in websockets.php config file.

CutePotato
  • 191
  • 1
  • 8