laravel / reverb

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

Reverb with Self-Signed Certificate and Supervision as Queue Worker #183

Closed Pixolantis closed 2 months ago

Pixolantis commented 2 months ago

Reverb Version

1.0.0-beta9

Laravel Version

11.0.7

PHP Version

8.3.6

Description

My Reverb runs with supervision and have the tls verification disabled: conf(broadcasting.php

'client_options' => [
    'verify' => false,
],

I run my queue for a test example with ´php artisan queue:work´ or ´queue:listen´. Both works.

With Queues and supervisor I get this error

Pusher error: cURL error 7: Failed to connect to reverb.aaa.test port 443 after 4 ms: Couldn't connect to server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://reverb.my-domain.test/apps/1949

Steps To Reproduce

My supervisor for queue:

[supervisord]
nodaemon=true
loglevel=info
user=laravel

[program:laravel-queue]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=laravel
numprocs=4
redirect_stderr=true
stdout_logfile=/var/www/html/storage/logs/queue.log
stopwaitsecs=3600

My dockerfile for supervisor:

...
RUN apk add --update supervisor

ENTRYPOINT ["supervisord", "--nodaemon", "--configuration", "/etc/supervisor/conf.d/queue.conf"]

I don't know if this is a reverb problem or if I have a missconfiguration

joedixon commented 2 months ago

Hey @Pixolantis, what does your Reverb configuration look like? Could you share your reverb.php file and your REVERB_ prefixed environment variables?

Pixolantis commented 2 months ago

Hey @joedixon sure. Thank you.

.env

REVERB_SERVER_HOST=reverb
REVERB_SERVER_PORT=8088
REVERB_APP_ID=215436
REVERB_APP_KEY=3orxjgppvmqnognsh8us
REVERB_APP_SECRET=yryu2rb6wi5u7ct2r09a
REVERB_HOST=reverb.my-domain.test
REVERB_PORT=443
REVERB_SCHEME=https

reverb.php (no changes made) I have try to set verify_peer but after this, my browser can't connect to reverb

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | 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', '0.0.0.0'),
            'port' => env('REVERB_SERVER_PORT', 8080),
            'hostname' => env('REVERB_HOST'),
            'options' => [
                'tls' => [],
            ],
            'max_request_size' => env('REVERB_MAX_REQUEST_SIZE', 10_000),
            'scaling' => [
                'enabled' => env('REVERB_SCALING_ENABLED', false),
                'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
            ],
            'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | 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', 10_000),
            ],
        ],

    ],

];

reverb is start with supervision in a separate Container (reverb:8088) If I stop my queue worker container and run php artisan queue:work in my php Container it works.

joedixon commented 2 months ago

REVERB_SERVER_HOST=reverb looks wrong, that should more likely be REVERB_SERVER_HOST=0.0.0.0 as it should be a valid host on the server on which Reverb can run.

How are you applying SSL to the Reverb server?

Pixolantis commented 2 months ago

I don‘t think that is wrong. Reverb is working woth queue:work. If it is wrong, I think it was not working wor an artisan command.

reverb is the containername for my reverb host. I use Traefik to enroll my Dev Environment with SSL

joedixon commented 2 months ago

Hey @Pixolantis. Sorry, but this configuration is outside of my ability to provide assistance. I would recommend asking for help in one of our support channels: