Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mallaury's avatar

Use laravel wecsockets and Echo with SSL

Hello,

I'm having trouble configuring Laravel websockets and Echo with SSL. (Everything works fine without encryption).

Here are my settings:

Bootstrap.js

window.Echo = new Echo({
    'broadcaster' : 'pusher',
    'key': '123456789',
    'wsHost' : window.location.hostname,
    'wsPort' : 6001,
    'wssPort' : 6001,
    'forceTLS' : true,
    'disableStats' : true,
    'cluster' : 'eu',
    'encrypted' : 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'),
                'encrypted' => true,
                'host' => "127.0.0.1",
                'useTLS' => true,
                'port' => 6001,
                'scheme' => 'https',
                'curl_options' => [
                    CURLOPT_SSL_VERIFYHOST => 0,
                    CURLOPT_SSL_VERIFYPEER => 0,
                ]
            ],
        ],

config/websockets.php

'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,
            'encrypted' => true,
        ],
    ],

I have 2 problems:

  • On firefox, the connection with the WSS is not done... "the connection was interrupted while the page was loading."
  • On Chrome, it only works if I disable "peer_verify". Which doesn't help me, since my goal is to have an end-to-end encryption...

Do you have any ideas that would help me?

Thanks!

0 likes
4 replies
azimidev's avatar

To troubleshoot the SSL connection issues with Laravel websockets and Echo, you can follow these steps:

  • Verify SSL certificate: Ensure that your SSL certificate is valid and not expired. Also, check if the certificate is issued by a trusted certificate authority.

  • Check the websockets.php configuration: Ensure that the SSL settings in the websockets.php file are correct. Confirm that the encrypted option is set to true.

  • Verify the firewall configuration: Make sure that your firewall is not blocking the SSL connection.

  • Check the browser settings: Ensure that your browser is configured to allow SSL connections. Some browsers have options to ignore SSL certificate errors, make sure that this option is not enabled.

  • Disable SSL verification in curl options: If you have already tried disabling SSL verification in the curl_options, you can try re-enabling it and checking if it resolves the issue.

  • Use a different browser: If the issue persists, you can try accessing the SSL-encrypted websockets on a different browser and see if it works.

  • Check the logs: Check the logs of your websocket server and Laravel logs to see if there are any errors or messages related to the SSL connection issues.

By following these steps, you should be able to troubleshoot the SSL connection issues with Laravel websockets and Echo.

mallaury's avatar

@azimidev Thanks ChatGPT :) But I do not have any issues with my SSL Certificate. I am convinced that it is a config mistake...

1 like
azimidev's avatar

@mallaury Your config looks fine "HUMAN" other than your key is 123456789 and something you've got to check with your service as we cannot have a look at all your configs here! So I'm not convinced you are convinced. ;)

mallaury's avatar

@azimidev I think laravel-websockets is used as an alternative to pusher, so it doesn't matter what the id is

Please or to participate in this conversation.