0

I've been trying to get this WebSocket package running on my local Laravel project for about a week now and I can't seem to find a solution to the issue. I've followed the documentation, multiple tutorials and answers on Stack Overflow / Github, but I keep getting the same error. These are my configurations:

.env:

PUSHER_APP_ID=anyId
PUSHER_APP_KEY=anyKey
PUSHER_APP_SECRET=anySecret
PUSHER_APP_CLUSTER=eu


config/broadcasting:

'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'),
        'useTLS' => true,
        'encrypted' => false,
        'host' => '127.0.0.1',
        'port' => 6001,
        'scheme' => 'http',
        'curl_options' => [
            CURLOPT_SSL_VERIFYHOST => 0,
            CURLOPT_SSL_VERIFYPEER => 0,
        ]
    ],
]


config/websockets:

'apps' => [
    [
        'id' => env('PUSHER_APP_ID'),
        'name' => env('APP_NAME'),
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'path' => env('PUSHER_APP_PATH'),
        'capacity' => null,
        'enable_client_messages' => false,
        'enable_statistics' => true,
    ],
],


resources/js/bootstrap.js: There is also WebsocketEvent and controller which calls the broadcasting of the event, I haven't included them to keep this shorter.

import Echo from 'laravel-echo'

window.Pusher = require('pusher-js');

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

window.Echo.channel('DemoChannel')
    .listen('WebsocketEvent', (e) => {
       console.log(e);
    });


Front-end error: This only seems to be fine when I set enabledTransports: ['wss'] which represents the secure connection but default of enabledTransports: ['ws'] doesn't.

image

Back-end error: Always fails.

image

As you can see, I've added the curl options as recommended on https://github.com/beyondcode/laravel-websockets/issues/109 and I've set encrypted: false. Overall, I believe it is a certificate issue which is beyond my full comprehension but the tutorials I followed seem to get it working perfectly on their local environment without SSL certificates, etc. Also, it seems like other developers who are having similar issues are not getting answered (example), which is why I am posting this. Any help would be appreciated, thank you.

Mohammed
  • 35
  • 1
  • 7
  • Not sure, but https://stackoverflow.com/questions/62127601/connect-to-a-site-presenting-an-expired-root-certificate-in-the-certificate-bund shows there has been some recent problems with certificates. – Nigel Ren Jun 02 '20 at 13:12
  • Yes, it does seem like it. The tutorials I followed were recorded in 2018 and seem to work perfectly then. I also remember reading a post where it was working for someone but then started failing recently. – Mohammed Jun 02 '20 at 13:17
  • maybe this will help https://stackoverflow.com/a/61704796/7908390 – TEFO Jun 02 '20 at 15:08

0 Answers0