Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverb 1.4.4 doesn't work in Local Development #287

Closed
Urthawen opened this issue Dec 20, 2024 · 9 comments
Closed

Reverb 1.4.4 doesn't work in Local Development #287

Urthawen opened this issue Dec 20, 2024 · 9 comments

Comments

@Urthawen
Copy link

Reverb Version

1.4.4

Laravel Version

11.36.1

PHP Version

8.3

Description

I just try to update the Reverb version form 1.4.3 to 1.4.4 and i cann't make it work again. (I just revert to 1.4.3 to continue my work)
In production, the 1.4.4 version seems to work fine, so maybe my local installation is doomed.

For local development, I use Laravel Herd on Windows, and for some problems, I had to configure a nginx server inside Herd to make reverb working : wss-reverb-ssl.test.txt

Maybe my config is false, i got it from a git repo that has the same problem as me using Reverb on Laravel Herd Windows.

The error i get in my client :
echo.js:6 WebSocket connection to 'wss://wss-reverb-ssl.test/app/dvzli9g6ilve6ilpgg44?protocol=7&client=js&version=8.4.0-rc2&flash=false' failed:

All work very fine with Laravel Reverb 1.4.3

Tell me if you want more informations :)

Thanks

Steps To Reproduce

  • Use Herd on Windows
  • Install a Nginx server using the configuration that i provide to you
@crynobone
Copy link
Member

@iaidan This seems to be related to your PR #277 . Do you have any inside why this would cause an issue?

@sertxudev
Copy link

I'm using Laravel Herd 1.11.1, Reverb 1.4.4 and Laravel 11.36. Everything works as expected on Windows without changing any configuration.

@iaidan
Copy link
Contributor

iaidan commented Dec 23, 2024

After a brief look, you should be able to use the standard nginx config with the latest version after my PR.

It might be related to the config using a hard coded SSL certificate location.

I will make a fresh laravel install with herd and reverb, with your config to test. Will relay results or a fix.

@ejntaylor
Copy link

how did you get on @iaidan

@Urthawen
Copy link
Author

Hello everyone,

I tried to use the standard nginx config and still doesn't work.

Can you provide me your nginx config @iaidan please ?

@Urthawen
Copy link
Author

I'm using Laravel Herd 1.11.1, Reverb 1.4.4 and Laravel 11.36. Everything works as expected on Windows without changing any configuration.

Hello @sertxudev ! Can you provide me your nginx config, the part of reverb in your .env, and your broadcast/reverb config files please ? I will compare with mines. Thanks

@sertxudev
Copy link

Hello @sertxudev ! Can you provide me your nginx config, the part of reverb in your .env, and your broadcast/reverb config files please ? I will compare with mines. Thanks

Sure! My site's folder is named cuelist, so the domain is cuelist.test.

Before posting this I also uninstalled Herd from my computer, to check if it works with a fresh install.
It works without touching any Herd configuration, so your files should be the same.

.env
REVERB_APP_ID=1001
REVERB_APP_KEY="cuelist-ws"
REVERB_APP_SECRET="secret"
REVERB_HOST="cuelist.test"
REVERB_PORT=8080
REVERB_SCHEME=https

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
broadcast/reverb.php
<?php

declare(strict_types=1);

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'),
                '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),
        ],

    ],

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

    ],

];
%userprofile%\.config\herd\config\nginx\nginx.conf
worker_processes auto;

events {
    worker_connections  1024;
}

http {
    
types {
    text/html                                        html htm shtml;
    text/css                                         css;
    text/xml                                         xml;
    image/gif                                        gif;
    image/jpeg                                       jpeg jpg;
    application/javascript                           js;
    application/atom+xml                             atom;
    application/rss+xml                              rss;

    text/mathml                                      mml;
    text/plain                                       txt;
    text/vnd.sun.j2me.app-descriptor                 jad;
    text/vnd.wap.wml                                 wml;
    text/x-component                                 htc;

    image/avif                                       avif;
    image/png                                        png;
    image/svg+xml                                    svg svgz;
    image/tiff                                       tif tiff;
    image/vnd.wap.wbmp                               wbmp;
    image/webp                                       webp;
    image/x-icon                                     ico;
    image/x-jng                                      jng;
    image/x-ms-bmp                                   bmp;

    font/woff                                        woff;
    font/woff2                                       woff2;

    application/java-archive                         jar war ear;
    application/json                                 json;
    application/mac-binhex40                         hqx;
    application/msword                               doc;
    application/pdf                                  pdf;
    application/postscript                           ps eps ai;
    application/rtf                                  rtf;
    application/vnd.apple.mpegurl                    m3u8;
    application/vnd.google-earth.kml+xml             kml;
    application/vnd.google-earth.kmz                 kmz;
    application/vnd.ms-excel                         xls;
    application/vnd.ms-fontobject                    eot;
    application/vnd.ms-powerpoint                    ppt;
    application/vnd.oasis.opendocument.graphics      odg;
    application/vnd.oasis.opendocument.presentation  odp;
    application/vnd.oasis.opendocument.spreadsheet   ods;
    application/vnd.oasis.opendocument.text          odt;
    application/vnd.openxmlformats-officedocument.presentationml.presentation
                                                     pptx;
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
                                                     xlsx;
    application/vnd.openxmlformats-officedocument.wordprocessingml.document
                                                     docx;
    application/vnd.wap.wmlc                         wmlc;
    application/wasm                                 wasm;
    application/x-7z-compressed                      7z;
    application/x-cocoa                              cco;
    application/x-java-archive-diff                  jardiff;
    application/x-java-jnlp-file                     jnlp;
    application/x-makeself                           run;
    application/x-perl                               pl pm;
    application/x-pilot                              prc pdb;
    application/x-rar-compressed                     rar;
    application/x-redhat-package-manager             rpm;
    application/x-sea                                sea;
    application/x-shockwave-flash                    swf;
    application/x-stuffit                            sit;
    application/x-tcl                                tcl tk;
    application/x-x509-ca-cert                       der pem crt;
    application/x-xpinstall                          xpi;
    application/xhtml+xml                            xhtml;
    application/xspf+xml                             xspf;
    application/zip                                  zip;

    application/octet-stream                         bin exe dll;
    application/octet-stream                         deb;
    application/octet-stream                         dmg;
    application/octet-stream                         iso img;
    application/octet-stream                         msi msp msm;

    audio/midi                                       mid midi kar;
    audio/mpeg                                       mp3;
    audio/ogg                                        ogg;
    audio/x-m4a                                      m4a;
    audio/x-realaudio                                ra;

    video/3gpp                                       3gpp 3gp;
    video/mp2t                                       ts;
    video/mp4                                        mp4;
    video/mpeg                                       mpeg mpg;
    video/quicktime                                  mov;
    video/webm                                       webm;
    video/x-flv                                      flv;
    video/x-m4v                                      m4v;
    video/x-mng                                      mng;
    video/x-ms-asf                                   asx asf;
    video/x-ms-wmv                                   wmv;
    video/x-msvideo                                  avi;
}

    default_type  application/octet-stream;

    sendfile on;
    keepalive_timeout  65;
    types_hash_max_size 2048;

    client_max_body_size 512M;

    server_names_hash_bucket_size 128;

    gzip  on;
    gzip_comp_level 5;
    gzip_min_length 256;
    gzip_proxied any;
    gzip_vary on;
    gzip_types
    application/atom+xml
    application/javascript
    application/json
    application/rss+xml
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-web-app-manifest+json
    application/xhtml+xml
    application/xml
    font/opentype
    image/svg+xml
    image/x-icon
    text/css
    text/plain
    text/x-component;
    
    include "C:/Users/Sergio/.config/herd/config/pro/nginx/*.conf";
    include "C:/Users/Sergio/.config/herd/config/valet/Nginx/*.conf";
    include herd.conf;
}
%userprofile%\.config\herd\config\valet\Nginx\cuelist.test.conf
server {
    listen 127.0.0.1:80;
    #listen 127.0.0.1:80; # valet loopback
    server_name cuelist.test www.cuelist.test *.cuelist.test;
    return 301 https://$host$request_uri;
}

server {
    listen 127.0.0.1:443 ssl;
    #listen VALET_LOOPBACK:443 ssl; # valet loopback
    server_name cuelist.test www.cuelist.test *.cuelist.test;
    root /;
    charset utf-8;
    client_max_body_size 512M;
    http2 on;

    location ~* /41c270e4-5535-4daa-b23e-c269744c2f45/([A-Z]+:)(.*) {
        internal;
        alias $1;
        try_files $2 $2/;
    }

    ssl_certificate "C:/Users/Sergio/.config/herd/config/valet/Certificates/cuelist.test.crt";
    ssl_certificate_key "C:/Users/Sergio/.config/herd/config/valet/Certificates/cuelist.test.key";

    location / {
        rewrite ^ "C:/Program Files/Herd/resources/app.asar.unpacked/resources/valet/server.php" last;
    }

    access_log off;
    error_log "C:/Users/Sergio/.config/herd/Log/nginx-error.log";

    error_page 404 "C:/Program Files/Herd/resources/app.asar.unpacked/resources/valet/server.php";

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        # Herd specific configuration, do not change
        fastcgi_pass $herd_sock;

        fastcgi_index "C:/Program Files/Herd/resources/app.asar.unpacked/resources/valet/server.php";
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME "C:/Program Files/Herd/resources/app.asar.unpacked/resources/valet/server.php";
        fastcgi_param HERD_HOME "C:/Users/Sergio/.config/herd";
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location ~ /\.ht {
        deny all;
    }
}

server {
    listen 127.0.0.1:60;
    #listen 127.0.0.1:60; # valet loopback
    server_name cuelist.test www.cuelist.test *.cuelist.test;
    root /;
    charset utf-8;
    client_max_body_size 128M;

    add_header X-Robots-Tag 'noindex, nofollow, nosnippet, noarchive';

    location ~* /41c270e4-5535-4daa-b23e-c269744c2f45/([A-Z]+:)(.*) {
        internal;
        alias /;
        try_files $uri $uri/;
    }

    location / {
        rewrite ^ "C:/Program Files/Herd/resources/app.asar.unpacked/resources/valet/server.php" last;
    }

    access_log off;
    error_log "C:/Users/Sergio/.config/herd/Log/nginx-error.log";

    error_page 404 "C:/Program Files/Herd/resources/app.asar.unpacked/resources/valet/server.php";

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass $herd_sock;
        fastcgi_index "C:/Program Files/Herd/resources/app.asar.unpacked/resources/valet/server.php";
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME "C:/Program Files/Herd/resources/app.asar.unpacked/resources/valet/server.php";
        fastcgi_param HERD_HOME "C:/Users/Sergio/.config/herd";
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location ~ /\.ht {
        deny all;
    }
}

FYI: To this project I also use Reverb as a Pusher server for an Electron project using laravel-echo and pusher-js, connects as expected with following code.

src/main/echo.ts
const options = {
    key: 'cuelist-ws',
    cluster: '',
    wsHost: 'cuelist.test',
    wsPort: 8080,
    wssPort: 8080,
    forceTLS: true,
    enabledTransports: ['ws', 'wss'] as Transport[],
    auth: {
        headers: {
            Authorization: `Bearer ${bearerToken}`,
        },
    },
    authEndpoint: 'https://cuelist.test/broadcasting/auth',
}

echo = new Echo({
    ...options,
    broadcaster: 'reverb',
    client: new Pusher(options.key, options),
})

@iaidan
Copy link
Contributor

iaidan commented Jan 16, 2025

Hi,
I have Reverb and Herd working on Windows.

After installing Herd, you do not need to make any configuration changes to nginx for it to work.

My nginx.conf matches that of @sertxudev's, identical other than different user / local domain.

@Urthawen
Copy link
Author

Well ! Thank you for sharing your configuration @sertxudev

All work fine now. I don't really now what happened. Maybe a fail configuration of my .env cause i just modify theses :

  • Modify .env
  • Add declare(strict_types=1); to reverb.php config file

I was sure that i had tried this .env file... Maybe i forgot to clear my configuration, i don't know.

Thank you all for the helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants