ninjapeps's avatar

Need help setting up for prod

(I keep getting a note saying I can't post links yet even though there aren't any links in my post so I've replaced http with hype)

I've got reverb working on my local machine. Now I'm having difficulty getting it to work on the server. I think I've finally gotten supervisor to run properly already so now my only issue is that the sockets can't be read. In the network tab of dev tools, the ws links all have the domain localhost:8080 and a status of blocked.

Not sure if the issue is with my env values

REVERB_APP_ID=396160  
REVERB_APP_KEY=ujjxjmewenx3ruqys4bf  
REVERB_APP_SECRET=ebqtdneudtyu3vategoj  
REVERB_SERVER_HOST=127.0.0.1  
REVERB_SERVER_PORT=6001  
REVERB_HOST="\<my site's url\>"  
REVERB_PORT=443  
REVERB_SCHEME=https  
BROADCAST_CONNECTION=reverb 

or with my Nginx config

I can't use 8080 because I get this error when I try:

Failed to listen on "tcp://127.0.0.1:8080": Address already in use (EADDRINUSE)

Any help would be appreciated. Thank you.

1 like
4 replies
vincent15000's avatar

Some suggestions :

  • is Reverb installed on the same server ?

  • have you a firewall that could block the access ?

  • have you authenticated the user for the broadcasting ?

channelAuthorization: {
    endpoint: '/api/broadcasting/auth',
    headers: {
        'Authorization': 'Bearer ' + sessionStorage.getItem('token'),
    },
},
return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        api: __DIR__.'/../routes/api_v1.php',
        commands: __DIR__.'/../routes/console.php',
        channels: __DIR__.'/../routes/channels.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        // $middleware->statefulApi();
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })
    ->withBroadcasting(
        __DIR__.'/../routes/channels.php',
        ['prefix' => 'api', 'middleware' => ['api', 'auth:sanctum']],
    )
    ->create();
ninjapeps's avatar

Yes, reverb is on the same server.

To my knowledge, there's no firewall blocking either 8080 or 6001.

User is authenticated.

1 like
vincent15000's avatar

I just set up an small real-time application with Laravel / InertiaJS / VueJS / Reverb and it works fine with this configuration.

// app.php => there is no noeed to add ->withBroadcasting()

<?php

use App\Http\Middleware\HandleInertiaRequests;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        channels: __DIR__.'/../routes/channels.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware): void {
        $middleware->web(append: [
            HandleInertiaRequests::class,
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions): void {
        //
    })->create();

// .env


REVERB_APP_ID=0123456789
REVERB_APP_KEY=0123456789
REVERB_APP_SECRET=0123456789
REVERB_HOST=localhost
REVERB_PORT=8080
REVERB_SCHEME=http

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

Have you started reverb on the server ?

JussiMannisto's avatar

I looked at your config briefly and noticed some things.

proxy_pass hype://0.0.0.0:6001; 

That address doesn't make sense in this context. Since your Reverb server is running locally, replace 0.0.0.0 with 127.0.0.1.

0.0.0.0 is a wildcard meaning "all IPv4 network interfaces" when listening on incoming traffic. But it doesn't work as a proxying target: you need an actual IP address for that.

Failed to listen on "tcp://127.0.0.1:8080": Address already in use (EADDRINUSE)

When are you getting this error? Is it when Supervisor tries to start the Reverb server?

That error means some other process is already listening on that port. Run this command to see what's up:

sudo ss -tulpn 'sport = :8080'

Other minor things:

listen \[::\]:443 quic;
listen 443 quic;
http3 off;

These settings are contradictory. You're opening two QUIC sockets for IPv4 and IPv6, but then you're turning off HTTP/3 support – the protocol that would actually use QUIC.

  if (-f $request_filename) {  
    break;  
  }  

This does nothing. Your try_files rule already routes everything to Laravel if the file doesn't exist on disk.

1 like

Please or to participate in this conversation.