beyondcode / laravel-websockets

Websockets for Laravel. Done right.
https://beyondco.de/docs/laravel-websockets
MIT License
5.08k stars 628 forks source link

No longer runs in Chrome #929

Closed robs007 closed 9 months ago

robs007 commented 2 years ago

I have had the websockets server running for a year with no issues. Last week for some reason it stopped working in chrome. It works fine in edge right now. Getting error wss://websockets.skydivect.net:6001/app/e1508ade4104796fcff7?protocol=7&client=js&version=4.3.1&flash=false' failed: WebSocket is closed before the connection is established. I get this error even on the websockets debug page. Running "beyondcode/laravel-websockets": "~2.0-dev" "laravel/framework": "^7.0", "pusher-js": "^5.1.1", "pusher/pusher-php-server": "~v4.1",

erikn69 commented 2 years ago

Maybe needs an upgrade of pusher/pusher-php-server to ^7.0

robs007 commented 2 years ago

I can try that, at one point I thought there were issues with pusher 7 and WebSockets and I had downgraded it.

erikn69 commented 2 years ago

composer require "beyondcode/laravel-websockets:dev-master" -W "pusher-js": "^7.0", "pusher/pusher-php-server": "^7.0",

robs007 commented 2 years ago

Now it doesn't even work in edge. I loaded a completely new websockets site using the above suggestions and I can't even get the debug console to work, I get the same error message now in chrome and edge.

erikn69 commented 2 years ago

https://github.com/beyondcode/laravel-websockets-demo/pull/22

robs007 commented 2 years ago

Yeah, that's basically what I have on the new server. "php": "^7.4|^8.0", "beyondcode/laravel-websockets": "dev-master", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "laravel/framework": "^8.75", "laravel/sanctum": "^2.11", "laravel/tinker": "^2.5" }, And I still get this error when trying to connect from the debug console. pusher.min.js:8

   WebSocket connection to 'wss://ws.skydivect.net:6002/app/e1508ade4104796fcff7?protocol=7&client=js&version=7.0.3&flash=false' failed: WebSocket is closed before the connection is established.
robs007 commented 2 years ago

Console is showing this, so it looks like it's running ws@ws02:~/site$ php artisan websockets:serve --port=6002 Starting the WebSocket server on port 6002... Saving statistics... Saving statistics...

erikn69 commented 2 years ago

https://github.com/beyondcode/laravel-websockets-demo/pull/22

Not works?

robs007 commented 2 years ago

You want me to load the demo?

robs007 commented 2 years ago

I loaded the demo, it does the same thing, I get the same error. This worked so well for so long, now I just can't get it to work. Don't know what changed.

robs007 commented 2 years ago

So, that actually does work when I'm on the local network, which would point to a firewall rule, but I haven't changed anything there in a long time. Well, at least I have a place to start looking now. Thanks for your help, the old version still doesn't work in chrome on the local network so I definitely need the upgrade. Thanks

robs007 commented 2 years ago

In the end, it's not a firewall issue. The debug panel works outside the network and it receives broadcasts. But I still get an error on the client pages from pusher closing instantly and not being able to connect. Does the wss mean it's trying to connect securely? I have not set up SSL on the server side. The server does have a certificate, but I have done no WebSockets set up.

WebSocket connection to 'wss://ws.skydivect.net:6002/app/e1508ade4104796fcff7?protocol=7&client=js&version=7.0.3&flash=false' failed: WebSocket is closed before the connection is established.

erikn69 commented 2 years ago

Does the wss mean it's trying to connect securely?

Yes

workaraund https://github.com/beyondcode/laravel-websockets/issues/920#issuecomment-1010956181 #921

robs007 commented 2 years ago

What controls it using wss over ws? Can I force it to use was?

genesiscz commented 2 years ago

It depends whether ur using https on not I think

genesiscz commented 2 years ago

Make sure the certificate is valid and the configuration too. Here's my part of broadcasting.php

image

Also websockets.php 'ssl' part:

image

MrReeds commented 2 years ago

Have the same problem, weirdly mine gets fixed when i restart my pc or server; haven't pinned down which is the cause. Works for most of people connected and then sometimes it just stops in some browsers (restarting browser does not help). since i use chrome (and edge is basically chrome) i dont know if this is also problem with firefox, but when testing, this is how i know it is one browser only. This happens to mostly in development: self signed certs, computer and vm going to sleep etc that can cause it. in prod it happens rarely and when it does i just restart the service and browser. Since dev did not support laravel 9, i switched over from ^2.0-dev to ^2.0.0-beta and am yet to see if it still occurs.

KyriakosMilad commented 2 years ago

Day one it's working, the next day it's not, nothing changed in the code, and nothing changed in the server config! I was debugging the issue for hours and got bored solving it and went to get lunch when I returned it was gone same code same server, I don't know how could that happen and I am afraid it's gonna break again tomorrow

kelvinthiongo commented 1 year ago

Guys I have never seen this websockets stuff work on production. I recommend seeking for alternatives coz it is semi abardoned, nkt! Try https://docs.soketi.app/.