laravel / reverb

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

WebSocket connection to Reverb server fails on HTTPS (wss) #219

Closed soufian212 closed 3 months ago

soufian212 commented 3 months ago

Reverb Version

1.0.0-beta

Laravel Version

11.9

PHP Version

8.3

Description

Expected Behavior:

Laravel Echo should establish a secure WebSocket connection (wss) to the Reverb server when using HTTPS.

Actual Behavior:

WebSocket connection fails on HTTPS with the error "WebSocket connection to 'wss://domain' failed: WebSocket is closed before the connection is established." The connection works successfully on HTTP.

I tried to add this on reverb.php config file

'tls' => [
                    'verify_peer' => false,
                    'allow_self_signed' => true,
                ],

but I'm still getting this error WebSocket connection to 'wss://domain' failed: WebSocket is closed before the connection is established.

my .env


APP_NAME=reverb
APP_ENV=local
APP_KEY=base64:xWZR/YJ/FOazZpgnukw2lw1hXYmMpB3bZr5kUMR4kRg=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=https://reverb.localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=reverb
DB_USERNAME=root
DB_PASSWORD=

SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=reverb
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

CACHE_STORE=database
CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"

REVERB_APP_ID=
REVERB_APP_KEY=
REVERB_APP_SECRET=0
REVERB_HOST="reverb.localhost"
REVERB_PORT=8080
REVERB_SCHEME=https
REVERB_SERVER_HOST=127.0.0.1

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

Steps To Reproduce

Configure Laravel Echo with the Reverb server address and credentials (broadcaster set to reverb). Set forceTLS to true in the Echo configuration. Run the application with HTTPS enabled. Observe the error message in the browser developer console.

driesvints commented 3 months ago

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.

Thanks!

joshharington commented 1 month ago

@soufian212 did you find a solution? I am running into the same issue, and been battling to find anything thats gets me further after 3 days of trying through SO, Discord, and forums.