WebSocket connection to 'wss://mydomain:6001/app/1234567890?protocol=7&client=js&version=5.0.2&flash=false' failed: Error in connection establishment: net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH
I'm getting this error. Its killing my time. I dig deep and found no proper solution for this issue. in **LOCAL SERVER its working fine **. but in LIVE SERVER this issue arises.
I put 'local_pk' and 'local_cert' both path inside websockets.php file
its my app.js file
window.Echo = new Echo({ broadcaster: 'pusher', key: '1234567890', wsHost: window.location.hostname, wsPort: 6001, encrypted: false, wssPort: 6001, disableStats: true, enabledTransports: ['ws', 'wss'], });
here is my broadcasing.hp config
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => '127.0.0.1',
'encrypted' => false,
'port' => 6001,
'scheme' => 'https',
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
]
],
],
PLEASE HELP ME OUT.
Same issue, tried several variations of config. Seems broken on newest Valet/Laravel? It's working fine with the exact same config on 1.1 and Laravel 5.8
@fahim152 I solved this in my ENV by providing both of my Valet certificates exact paths. Previously, I had them aliased to user path using ~/. If this is your case, you'll need to provide with exact paths.
okay thanks. I'm using my vps server and lets encrypt as ssl. I did provide private key and full chain key path on websockets.php , Not worked that time. gotta try again. Hope it will solve the issue
I'm using LetsEncrypt as well on my staging server. Are you using a PEM or CRT/KEY files? Let me know if it works for you.
I'm using LetsEncrypt as well on my staging server. Are you using a PEM or CRT/KEY files? Let me know if it works for you.
Hi I'm using like this into my laravel .env file: LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT=/etc/letsencrypt/live/app.socialhub.pro/fullchain.pem LARAVEL_WEBSOCKETS_SSL_LOCAL_PK=/etc/letsencrypt/live/app.socialhub.pro/privkey.pem
but I got the same erro :( Plase helpme if you can :)
With Laravel Forge, I plugged in both the crt and key files generated from LetsEncrypt. I am not working with the pem keys although I believe the documentation says you can.
Do you have the crt and key files? Maybe give those a try?
With Laravel Forge, I plugged in both the crt and key files generated from LetsEncrypt. I am not working with the pem keys although I believe the documentation says you can.
Do you have the crt and key files? Maybe give those a try?
I convert my cert.pem to .crt and my key.pem to .key. I'm trying to make work now...
Thanks for the quick answer :)
Nothing work with https :( only work with http!
I tried almost all combinations: //// My .vue component on start window.Echo = new Echo({ broadcaster: 'pusher', key: process.env.MIX_PUSHER_APP_KEY, cluster: process.env.MIX_PUSHER_APP_CLUSTER, wsHost: process.env.MIX_APP_HOST, // wsHost: window.location.hostname, wsPort: 6001, wssPort: 6001, // enabledTransports: ['ws'], enabledTransports: ['ws', 'wss'], // encrypted: true, encrypted: false, disableStats: false });
///// config/broadcasting.php
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
// 'encrypted' => true,
// 'scheme' => 'https',
'useTLS' => false,
'encrypted' => false,
'host' => env('APP_HOST'),
'port' => 6001,
'scheme' => 'http',
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
]
],
///// config/websockets.php
'ssl' => [
'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
// 'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
'passphrase' => null,
'verify_peer' => false,
],
Clear all laravel cache, npm run dev, composer dump-autoload -o, clear navigator cache, restart supervisor and websockets, and I still having websocket with https erros like:
WebSocket connection to 'wss://[MYDOMINE]:6001/app/NNN?protocol=7&client=js&version=5.0.3&flash=false' failed: WebSocket is closed before the connection is established.
@fahim152 , I had the same issue as yours. I am also using a vps server, and positive ssl. I ended up switching from https to http and I added this code to my .htaccess file to point to http as so
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
And it works!
I am thinking it has to do with the ssl. Each time, I switch to https I get an error similar to yours:- " Firefox can't establish a connection to the server at wss://mydomain/app/1234567890?protocol=7&client=js&version5.0.3&flash=false. " " The connection at wss://mydomain/app/1234567890?protocol=7&client=js&version5.0.3&flash=false was interrupted while page was loading".
I am still investigating, if i find the solution, i will update it here.
@UchennaPrudensia unfortunately your soluction not use https, like mine :( I'm still facing this problem whitout success... http work perfect, https not, i'm thinking buy another sertificate files... I'm using certificates from "letsencrypt", and its are free, I do not know if it make sence...
thanks
Hey Guys, i just solved the same problem by running websockets with sudo: sudo php artisan websockets:serve
this solved my problem! Thanks @fahim152
I am having the same issue : failed: Error in connection establishment: net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH
// broadcast.php setting 'pusher' => [ 'driver' => 'pusher', 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), 'host' => '127.0.0.1', 'port' => 6001, 'scheme' => 'https', 'curl_options' => [ CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0, ] ], ],
// echo settings import Echo from "laravel-echo";
window.Pusher = require('pusher-js');
window.Echo = new Echo({ broadcaster: 'pusher', key: 'myKey', wsHost: window.location.hostname, wsPort: 6001, wssPort: 6001, encrypted: true, disableStats: true, enabledTransports: ['ws', 'wss'], });
ssl configured with signed certificate according to the documentation but still facing this issue
@AyazTechloyce try running websockets with sudo like this:
sudo php artisan websockets:serve
this solved my problem
The reason sudo works is because there is a permissions problem on the cert files for the web service user. You can copy the key and cert (or change the current permissions) to an accessible location and it will work fine for the web user to run the artisan command. If you are using letsencrypt or certbot or something to renew your certs that will be a continual problem I think. It also seems a bit insecure to allow the web user access to the the key file if you got compromised. So not really a production solution like reverse-proxy through nginx would be. For the live server I found it better to set up the websocket as http and let nginx handle the ssl encryption.
@joshcalloway can you make laravel-websockets work on port 80 instead of 6001 ? I have tried all configurations possible, this is my current nginx config:
server {
root /var/www/html/websockets-domain/public;
index index.html index.htm index.php;
server_name ws-test.domain.com;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:6001/;
add_header X-location websocket always;
}
location /laravel-websockets {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/ws-test.domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ws-test.domain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
I tried variants with: location /app/ { ...
but it keeps giving me a 502 error.
I don't know how to make it work. :(
I think you probably could. I followed the directions at https://docs.beyondco.de/laravel-websockets/1.0/basic-usage/ssl.html#usage-with-a-reverse-proxy-like-nginx to make it work over 443 but it seems like it would just as easy to proxy 80 instead. Here is a copy of my config running on a subdomain
`server { listen 443 ssl http2; listen [::]:443 ssl http2;
server_name {{ dev_socket_domain }}; set $base {{ dev_site_path }}; root $base/current/public;
SSL
ssl_certificate /etc/letsencrypt/live/{{ dev_socket_domain }}/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/{{ dev_socket_domain }}/privkey.pem;
Logging
access_log /var/log/nginx/{{ dev_socket_domain }}.access.log; error_log /var/log/nginx/{{ dev_socket_domain }}.error.log warn;
Fallback
location / { proxy_pass http://127.0.0.1:6001; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-VerifiedViaNginx yes;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
# Specific for websockets: force the use of HTTP/1.1 and set the Upgrade header
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;
}
General Config
include includes/general.conf; }`
@joshcalloway thanks for the help, but it didnt work. I keep getting this error: Error during WebSocket handshake: Unexpected response code: 502
event on por 80 if i disable ssl the error persists.
If I try to connect directly on port 6001, it works fine.
The problem is the .pem certificates. I had the same problem with the .pem certificates, installed new .crt and .key and it worked properly.
I don't thing so, cause I have now working a .pem and a .key file: 'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', '/etc/letsencrypt/live/app.socialhub.pro/fullchain.pem'),
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', '/etc/letsencrypt/live/app.socialhub.pro/privkey.key'),
but my .pem is now a fullchain certificate, it mean it have two certificates in the same file!
Hope it help, because I spend precious time to get it working
Had a similar issue. Invested almost half a day and finally what worked?
[ I am using Letsencrypt > and https. FYI ]
as @ricardoperovano suggested, sudo php artisan websockets:serve
Did the trick for me. Thanks mate.
Cheers