6

I'm using replacement of Pusher Laravel Webaockets package.

In my application Laravel Echo tries to connect vía wss instead ws, so it fails.

My resources/js/bootstrap.js:

import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    wsHost: window.location.hostname,
    wsPort: 6001,
    disableStats: true,
    encrypted: false,
    enabledTransports: ['ws'],
});

Broadcast connection in 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' => false,
                'host' => '127.0.0.1',
                'port' => 6001,
                'scheme' => 'http',
            ],
        ],

My .env:

BROADCAST_DRIVER=pusher
...
PUSHER_APP_ID=1122334455
PUSHER_APP_KEY=lkjdsofsd9f8sd98f7s9dfuosdff9s87fsuyfsd76f8s7df6
PUSHER_APP_SECRET=secret1122334455fsdf897sd98f7sd88sd7f9s8d7f
PUSHER_APP_CLUSTER=eu

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_PUERTO_WEBSOCKETS="${LARAVEL_WEBSOCKETS_PORT}"

When a page of my application loads, inspecting the console I can see:

wss instead wsGET wss://localhost/app/lkjdsofsd9f8sd98f7s9dfuosdff9s87fsuyfsd76f8s7df6?protocol=7&client=js&version=6.0.3&flash=false

But if I run http://localhost:8000/laravel-websockets the request is vía ws and it's successfull:

enter image description here

Can you help me? Thanks

Jaime
  • 328
  • 1
  • 6
  • 19

1 Answers1

1

Donwgrade pusher.js to 4.3 .Dont forget to compile afterwards.

Mihai
  • 26,325
  • 7
  • 66
  • 81
  • 2
    I don't like when downgrading is the solution ... but that fixed the problem. Thanks! – Jaime Jun 07 '20 at 11:30
  • 7
    You could also set ``forceTLS: false``; when you bootsrap Echo. Source: https://github.com/beyondcode/laravel-websockets/issues/378#issuecomment-650551745 – Benx Sep 23 '21 at 11:20
  • 1
    No need to downgrade, just as @ZigaBenko said, set forceTLS to false. – Rezasys Sep 28 '21 at 17:56