laravel-websockets icon indicating copy to clipboard operation
laravel-websockets copied to clipboard

laravel-websocket not working on hosting but works on localhost

Open SachinBahukhandi opened this issue 7 years ago • 18 comments

Hi there, I tried this awesome library and everything seemed to be working as expected but does not work on the production server. Whenever I tried calling it does not work. Instead, it shows this error:

WebSocket is closed before the connection is established.

I have already tried the answers mentioned in the #191 but no avail. Kindly help me out. Thank you.

SachinBahukhandi avatar Jun 19 '19 15:06 SachinBahukhandi

Same problem

Getting the above error or else

Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

xlcrr avatar Jun 21 '19 19:06 xlcrr

Is there any solutions to this problem?

SachinBahukhandi avatar Jun 21 '19 19:06 SachinBahukhandi

Once I get it working I will let you know...

xlcrr avatar Jun 21 '19 19:06 xlcrr

Tried and tired of this not working at all. I have tried almost everything and even tried to modify the data inside bootstrap.js and then tried executing npm run dev. But no avail.

SachinBahukhandi avatar Jun 21 '19 19:06 SachinBahukhandi

I pushed my npm run dev vue code to production and it seems to be failing at

   createWebSocket: function (url) {
        var Constructor = this.getWebSocketAPI();
	return new Constructor(url); // here 
    },

xlcrr avatar Jun 21 '19 19:06 xlcrr

  window.Echo = new Echo({
  broadcaster: 'pusher',
  key: process.env.MIX_PUSHER_APP_KEY,
  cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  wsHost: window.location.hostname,
  wsPort: 6001,
  wssPort: 6001,
  disableStats: true,
  enabledTransports: ['ws', 'wss']
  });

Did not modify the code but just as it was listed in #96

SachinBahukhandi avatar Jun 21 '19 20:06 SachinBahukhandi

Make sure you opened port 6001 on your server's firewall.

francislavoie avatar Jul 30 '19 02:07 francislavoie

I have same problem, and I have tried to solve this by the command sudo ufw allow 6001 but still the issue remains. Everything is working on local machine. My server config is ubuntu 18.04, apache2.

amirreza1751 avatar Feb 06 '20 04:02 amirreza1751

Do ports have other configurations more than allowing on firewall which I must apply?

amirreza1751 avatar Feb 06 '20 05:02 amirreza1751

Hi there i am also facing same issue it is working in my local perfectly but on host i am not able to run i tried all tthe ways but no use,Can anyone help me out of this.

GopiPacha1996 avatar May 29 '20 10:05 GopiPacha1996

any solution any body finds?

bilalswiftsolutions avatar Oct 02 '20 07:10 bilalswiftsolutions

Any solution??

AnikaApsara avatar Jan 26 '21 06:01 AnikaApsara

Yeah please make sure your config/broadcast.php is having proper pusher credentials and also another file config/websockets.php. Please make a proper configuration on " resources/js/bootstrap.js". And also check whether you ufw enabled or not even if it disabled Please open that particular port with command " ufw allow '

Gopi0605 avatar Jan 26 '21 09:01 Gopi0605

You can find a working solution here https://github.com/OpenLitterMap/openlittermap-web

xlcrr avatar Jan 26 '21 10:01 xlcrr

Is there any solutions to this problem? may be you can find a working solution here https://stackoverflow.com/questions/65363295/laravel-websocket-is-not-connect-on-live-server

AbdulHanan12 avatar Feb 04 '21 08:02 AbdulHanan12

i have the same issue

allamo123 avatar Nov 11 '21 19:11 allamo123

I got this issue too, Tried with any thing I have: Use nginx proxy with ssl on https site always error:

❯ wscat -c "wss://domain.tld:6001/app/849dd8699?protocol=7&client=js&version=7.0.3&flash=false"
error: write EPROTO 140034167490432:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:../deps/openssl/openssl/ssl/record/rec_layer_s3.c:1544:SSL alert number 40

using IP:

wscat -c "<server_id>:6001/ws/app/849dd8699?protocol=7&client=js&version=7.0.3&flash=false"
error: socket hang up

using domain without port:

❯ wscat -c "wss://domain.tld/ws/app/849dd8699?protocol=7&client=js&version=7.0.3&flash=false"
error: Unexpected server response: 502

any update for this error?

anthony9981 avatar Nov 25 '21 07:11 anthony9981

open port 6001 in host

mahdi4187 avatar Jan 24 '22 13:01 mahdi4187