how to use CloudFlare SSL in Laravel-websockets

Viewed 1108

my project hosted in digitalocean and I have connected domain to server using cloudflare. I using SSL. But WSS connection does not work. I got this error message WebSocket connection to 'wss://mywebsite.com/app/ABCDEFG?protocol=7&client=js&version=6.0.3&flash=false' failed: Error during WebSocket handshake: Unexpected response code: 404

I have apache2 server

my config/broadcasting.php looks like

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

and client side bootstrap.js looks like

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    forceTLS: false,
    encrypted:true,
    wsHost: window.location.hostname,
    wsPort: 2053,
    wssPort: 2053,
    disableStats: true,
    enabledTransports:['ws','wss'],

});

and I running command php artisan websockets:serve --port=2053

if you want any additional information please write comment. anyone have solution? thanks

new error failed: WebSocket is closed before the connection is established.

0 Answers
Related