laravel / reverb

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

WebSocket Connection Fails with SSL and Laravel Event Dispatching Error #88

Closed karaOdin closed 8 months ago

karaOdin commented 8 months ago

Reverb Version

@beta

Laravel Version

11.0.3

PHP Version

8.2

Description

I am currently facing an issue with my Laravel application when I try to use SSL. The application works fine without SSL, but when I add a Let's Encrypt SSL certificate, the WebSocket connection fails. Here is my Nginx configuration:

map $http_upgrade $type { default "web"; websocket "ws"; } server { listen 80; listen [::]:80; root /home/ploi/reverb.devcloud.dz/public; server_name reverb.devcloud.dz; include /etc/nginx/ssl/reverb.devcloud.dz; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'; ssl_prefer_server_ciphers on; ssl_dhparam /etc/nginx/dhparams.pem; index index.php index.html; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; charset utf-8; include /etc/nginx/ploi/reverb.devcloud.dz/server/; location / { try_files /nonexistent @$type; } location @web { try_files $uri $uri/ /index.php?$query_string; } location @ws { proxy_pass http://0.0.0.0:8080; proxy_set_header Host $host; proxy_read_timeout 60; proxy_connect_timeout 60; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } access_log off; error_log /var/log/nginx/reverb.devcloud.dz-error.log error; location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ .php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/run/php/php8.2-fpm.sock; fastcgi_buffers 16 16k; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; include fastcgi_params; } location ~ /.(?!well-known). { deny all; } }

Additionally, when I dispatch an event, the job fails and I receive the following error:

[2024-03-14 18:56:42] production.ERROR: Pusher error: cURL error 28: Operation timed out after 10001 milliseconds with 0 out of 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://reverb.devcloud.dz:8080/apps/100838/events?auth_key=7vifn5r8izbayiijog1r&auth_timestamp=1710442592&auth_version=1.0&body_md5=71097622162ba803476e118aee1fabc5&auth_signature=e3e95e6e2edc190b1f7887a0c2786d04e73a76825cc5986dea440d572e75a87f. {"exception":"[object] Screenshot from 2024-03-14 19-48-55

Steps To Reproduce

And this is my .env conf

REVERB_APP_ID=100838 REVERB_APP_KEY=7vifn5r8izbayiijog1r REVERB_APP_SECRET=vr3ptchygcmdq6peri5f REVERB_HOST="reverb.devcloud.dz" REVERB_PORT=8080 REVERB_SCHEME=https

BROADCAST_CONNECTION=reverb

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}" VITE_REVERB_HOST="reverb.devcloud.dz" VITE_REVERB_PORT=443 VITE_REVERB_SCHEME="${REVERB_SCHEME}"

yourchocomate commented 8 months ago

Try again with 127.0.0.1 instead 0.0.0.0 at nginx confg proxy_pass

karaOdin commented 8 months ago

Try again with 127.0.0.1 instead 0.0.0.0 at nginx confg proxy_pass

Yes but unfortunately didn't work with me

fylzero commented 8 months ago

@karaOdin This issue is very similar, if not duplicating: https://github.com/laravel/reverb/issues/78

driesvints commented 8 months ago

Let's please focus on #78