laravel / reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.
https://reverb.laravel.com
MIT License
1.07k stars 82 forks source link

vite and reverb scheme is http on production but still sending wss #208

Closed aftabkhaliq86 closed 3 months ago

aftabkhaliq86 commented 3 months ago

Reverb Version

@beta

Laravel Version

11

PHP Version

8.2

Description

soccket is trying to connect with wss instead of ws | in env my pusher and revert scheme is set to http but my site is secure using https is there anywas that when website is in https and scheme set to http it should connect with ws:/

image

because am using cpnael apache and lets encrypt ssl if i add private & publc key to a specific file to make it work with ssl
in browser i get this when i hit this url

https://help.changer4u.com:8080/app/2ur0etpghgqsfvwbdllm?protocol=7&client=js&version=8.4.0-rc2&flash=false

image and if i cancel this promt connect work but thats not the solution i guess

Steps To Reproduce

soccket is trying to connect with wss instead of ws | in env my pusher and revert scheme is set to http but my site is secure using https is there anywas that when website is in https and scheme set to http it should connect with ws:/

joedixon commented 3 months ago

I'm afraid if the page you are connecting to the Reverb server from is served over HTTPS, the Pusher SDK (used under the hood by Echo), will force secure WebSockets (wss).

aftabkhaliq86 commented 3 months ago

i am able to made conection with reverb but during broadcasting message am getting this error now image

joedixon commented 3 months ago

Can you try running the server with the --debug option and seeing if there is any error reported?

abrhamsw commented 3 months ago

Reverb Version

@beta

Laravel Version

11

PHP Version

8.2

Description

soccket is trying to connect with wss instead of ws | in env my pusher and revert scheme is set to http but my site is secure using https is there anywas that when website is in https and scheme set to http it should connect with ws:/

image

because am using cpnael apache and lets encrypt ssl if i add private & publc key to a specific file to make it work with ssl in browser i get this when i hit this url

https://help.changer4u.com:8080/app/2ur0etpghgqsfvwbdllm?protocol=7&client=js&version=8.4.0-rc2&flash=false

image and if i cancel this promt connect work but thats not the solution i guess

Steps To Reproduce

soccket is trying to connect with wss instead of ws | in env my pusher and revert scheme is set to http but my site is secure using https is there anywas that when website is in https and scheme set to http it should connect with ws:/

Can you share your Proxy Configuration? It is not working on my side, am using cpnael apache and lets encrypt ssl

aftabkhaliq86 commented 3 months ago

@abrhamsw to configure it on panel using lets encrypt follow these configurations env BROADCAST_DRIVER=reverb BROADCAST_CONNECTION=reverb

in your broadcasting.php file in config folder add these

 'reverb' => [
        'driver' => 'reverb',
        'key' => env('REVERB_APP_KEY'),
        'secret' => env('REVERB_APP_SECRET'),
        'app_id' => env('REVERB_APP_ID'),
        'options' => [
            'host' => env('REVERB_HOST'),
            'port' => env('REVERB_PORT', 443),
            'scheme' => 'https',
            'useTLS' => 'true',
             'curl_options' => [
         'CURLOPT_SSL_VERIFYHOST' => 0,
         'CURLOPT_SSL_VERIFYPEER' => 0,
     ],
        ],
        'client_options' => [
            // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
           'verify' => false,
            ],
        ],

        in config folder add these  in reverb.php 
            'servers' => [

    'reverb' => [
        'host' => env('REVERB_SERVER_HOST', '0.0.0.0'),
        'port' => env('REVERB_SERVER_PORT', 8080),
        'hostname' => env('REVERB_HOST'),
        'options' => [
            'tls' => [
                'local_cert' => env('REVERB_LOCAL_CERT',null),
                'local_pk' => env('REVERB_LOCAL_PK',null),
                        'passphrase' => null,
                        'verify_peer'=>false,
                        'verify_peer_name'=>false,
                ],
        ],
        'max_request_size' => env('REVERB_MAX_REQUEST_SIZE', 10_000),
        'scaling' => [
            'enabled' => env('REVERB_SCALING_ENABLED', false),
            'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
            'server' => [
                'url' => env('REDIS_URL'),
                'host' => env('REDIS_HOST', '127.0.0.1'),
                'port' => env('REDIS_PORT', '6379'),
                'username' => env('REDIS_USERNAME'),
                'password' => env('REDIS_PASSWORD'),
                'database' => env('REDIS_DB', '0'),
            ],
        ],
        'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
        'telescope_ingest_interval' => env('REVERB_TELESCOPE_INGEST_INTERVAL', 15),
    ],

],

for these values
  'local_cert' => env('REVERB_LOCAL_CERT',null),
                'local_pk' => env('REVERB_LOCAL_PK',null),

                go to SSL/tls status select domain and copy public and private key put them in separate files and add their path 

                happy coding
abrhamsw commented 3 months ago

Proxy

Thank You, but how about Reverse Proxy configuration for Apache

aftabkhaliq86 commented 3 months ago

Proxy

Thank You, but how about Reverse Proxy configuration for Apache

just follow these instructions on apache you don't need a proxy ...