DEV Community

Nguyen Hoang
Nguyen Hoang

Posted on

reverb + websocket

apache:



<VirtualHost *:443>
   SSLEngine on
  SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
  SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

  ServerName local-talktoc.local
  DocumentRoot "d:/wamp64/www/talktoc/public"
  <Directory  "d:/wamp64/www/talktoc/public/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
  <IfModule fcgid_module>
    Define FCGIPHPVERSION "8.2.19"
    FcgidInitialEnv PHPRC ${PHPROOT}${FCGIPHPVERSION}
    <Files ~ "\.php$">
      Options +Indexes +Includes +FollowSymLinks +MultiViews +ExecCGI
      AddHandler fcgid-script .php
      FcgidWrapper "${PHPROOT}${FCGIPHPVERSION}/php-cgi.exe" .php
    </Files>
  </IfModule>



    RewriteEngine On
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteCond %{HTTP:Connection} upgrade$ [NC]
  RewriteRule ^/app(.*)$ ws://127.0.0.1:6001/app$1 [P,L]

  ProxyPass /app ws://127.0.0.1:9000/app
  ProxyPassReverse /app ws://127.0.0.1:6001/app


  RewriteCond %{REQUEST_URI} ^/app [NC]
  RewriteRule ^/app(.*)$ http://127.0.0.1:6001/app$1 [P,L]

  ProxyPass /app http://127.0.0.1:9000/app
  ProxyPassReverse /app http://127.0.0.1:6001/app
</VirtualHost>


Enter fullscreen mode Exit fullscreen mode

php artisan reverb:start --debug

Image description

follow doc laravel 11 install reverb
.env

BROADCAST_CONNECTION=reverb

REVERB_APP_ID=476901
REVERB_APP_KEY=jw38n468iscll35fdi6q
REVERB_APP_SECRET=aicmdzwcwcd63xgpuclr
REVERB_HOST="local-talktoc.local"
REVERB_PORT=443
REVERB_SCHEME=https

REVERB_SERVER_HOST="127.0.0.1"
REVERB_SERVER_PORT=6001

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"

QUEUE_CONNECTION=sync

config/reverb.php

<?php

return [

/*
Enter fullscreen mode Exit fullscreen mode

|--------------------------------------------------------------------------
| Default Reverb Server
|--------------------------------------------------------------------------
|
| This option controls the default server used by Reverb to handle
| incoming messages as well as broadcasting message to all your
| connected clients. At this time only "reverb" is supported.
|
*/

'default' => env('REVERB_SERVER', 'reverb'),

/*
|--------------------------------------------------------------------------
| Reverb Servers
|--------------------------------------------------------------------------
|
| Here you may define details for each of the supported Reverb servers.
| Each server has its own configuration options that are defined in
| the array below. You should ensure all the options are present.
|
*/

'servers' => [

    'reverb' => [
        'host' => env('REVERB_SERVER_HOST', '127.0.0.1'),
        'port' => env('REVERB_SERVER_PORT', 6001),
        'hostname' => env('REVERB_HOST'),
        'options' => [
            'tls' => [
Enter fullscreen mode Exit fullscreen mode

// 'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT'),
// 'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK'),
],
],
'scaling' => [
'enabled' => env('REVERB_SCALING_ENABLED', false),
'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
],
'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
'log' => true
],

],

/*
|--------------------------------------------------------------------------
| Reverb Applications
|--------------------------------------------------------------------------
|
| Here you may define how Reverb applications are managed. If you choose
| to use the "config" provider, you may define an array of apps which
| your server will support, including their connection credentials.
|
*/

'apps' => [

    'provider' => 'config',

    'apps' => [
        [
            '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' => env('REVERB_SCHEME', 'https'),
                'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
            ],
            'allowed_origins' => ['*'],
            'ping_interval' => env('REVERB_APP_PING_INTERVAL', 60),
            'max_message_size' => env('REVERB_APP_MAX_MESSAGE_SIZE', 10000),
        ],
    ],

],
Enter fullscreen mode Exit fullscreen mode

];

config/broadcasting.php

'connections' => [
'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' => env('REVERB_SCHEME', 'https'),
'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
'encrypted' => false,
],
'client_options' => [
'verify' => false,
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],

use postman debug

Top comments (0)