Reverb Version
@beta
Laravel Version
^11.0
PHP Version
8.2
Description
Hi, I’m having problems with the reverb in production, remembering that ‘locally’ everything works. (apache + lightsail aws + lamp 8.2)
Follow my .env config:
BROADCAST_CONNECTION=reverb
REVERB_SERVER_HOST=0.0.0.0
REVERB_SERVER_PORT=8080
REVERB_APP_ID=xxx
REVERB_APP_KEY=xxx
REVERB_APP_SECRET=xxx
REVERB_HOST="mydomain.com"
REVERB_PORT=443
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}"
routes/channel.php
onlye:
Broadcast::channel('update_coins.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
resources/js/echo.js
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'reverb',
key: import.meta.env.VITE_REVERB_APP_KEY,
wsHost: import.meta.env.VITE_REVERB_HOST,
wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
});
my vhosts:
boost-https-vhost.conf:
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache/conf/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache/conf/server.key"
DocumentRoot "/opt/bitnami/apache/htdocs/boost/public"
<Directory "/opt/bitnami/apache/htdocs/boost/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ProxyPass "/app" "ws://0.0.0.0:8080/app"
ProxyPassReverse "/app" "ws://0.0.0.0:8080/app"
</VirtualHost>
boost-vhost.conf:
<VirtualHost *:80>
DocumentRoot "/opt/bitnami/apache/htdocs/boost/public"
<Directory "/opt/bitnami/apache/htdocs/boost/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
.htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# ROUTER WWW Redirect.
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# ROUTER HTTPS Redirect
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
remembering that everything works locally, but not in production!
when I try to run a test command:
$user_id = 1;
$user = User::find($user_id);
$user->update(['coins' => $user->coins + 100]);
UpdateCoinsEvent::dispatch($user);
the following error is thrown:
local.ERROR: Pusher error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Not Found</title>
{"exception":"[object] (Illuminate\Broadcasting\BroadcastException(code: 0): Pusher error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Not Found</title>
Steps To Reproduce
protected $signature = 'coins';
protected $description = 'Command description';
public function handle()
{
$user_id = 1;
$user = User::find($user_id);
$user->update(['coins' => $user->coins + 100]);
UpdateCoinsEvent::dispatch($user);
}
error:
local.ERROR: Pusher error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Not Found</title>
{"exception":"[object] (Illuminate\Broadcasting\BroadcastException(code: 0): Pusher error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Not Found</title>
remembering that everything works locally, but not in production!