failed: WebSocket is closed before the connection is established.
First of all. thanks for building this package!
For some reason, I get this message in the console whenever I terminate and re-run websockets:serve.
failed: WebSocket is closed before the connection is established.
The only way I've found to successfully get back up and running is to change PUSHER_APP_KEY in config and bootstrap.js and npm run dev.
I'm worried this will have problems in production. Am I missing something or is there a better way to terminate and restart the websocket server?
(Laravel 5.7 on Homestead)
I'm seeing the same error message in the browser. I've been unable to reliably connect, it's very intermittent.
In the artisan terminal I can see that it connects for a split second and then immediately disconnects:
New connection opened for app key app.
Connection id 576957883.192427708 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"576957883.192427708\",\"activity_timeout\":30}"}
Connection id 576957883.192427708 closed.
Composer: laravel/framework: 5.7.19 beyondcode/laravel-websockets: 1.0.4 pusher/pusher-php-server: 3.3.0
NPM: laravel-echo: 1.5.2 pusher-js: 4.3.1
I was able to circumvent this error by specifying enabledTransports in my JS config:
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
wsHost: window.location.hostname,
wsPort: 6001,
disableStats: true,
enabledTransports: ['ws', 'wss'] // <- added this param
});
Otherwise the pusher-js api tries to connect to the official Pusher service.
I'm still seeing this issue (in production only, not locally)
Composer: laravel/framework: 5.8.3 beyondcode/laravel-websockets: 1.1.1 pusher/pusher-php-server: 3.3.1
NPM: laravel-echo: 1.5.3 pusher-js: 4.4.0
@simplethemes That worked for me.
I am also facing the same issue is there any solution found?
Me too. Did anyone found a solution for this problem?
I had faced same issue.
In my case I found out it only occurred on Windows Edge browser.
When I switched to Chrome or Opera the issue disappeared.
I am only facing this error on production host.
clear the cookies, specifically PusherTransportNonTLS
do you think that this issue can be related to cluster? Because I am getting the same error. I have checked all documentation still didn't find anything. it was working good before on server but once I reuploaded my files the error started to happing do you think this issue is related to port or cluster??
@simplethemes solution worked
enabledTransports: ["ws", "wss"],
it is not working for me! I have added this line still getting error wss://secretscrush.com:6001/app/keyisnotitswhatyouthink?protocol=7&client=js&version=4.4.0&flash=false' Websockets is closed before established
hello! guys. php artisan optimize:clear and sudo php artisan websockets:serve worked for me. try it
PusherTransportNonTLS
For some reason it isn't working in my Brave Browser, but it's working in my Chrome Brower. Then i did a quick search about "Websockets not working in Brave Brower" then saw this - https://community.brave.com/t/browser-is-having-issues-with-wss-websocket-secure/70209/7
I fixed this issue by using an older version of pusher-js. 4.3.1 is the one used in the demo/dashboard so I switched to that
Downgrading to npm install [email protected] still works in October 2020
Check your port that it is not disabled.
ufw allow 6001 - open this port
Check your port that it is not disabled.
ufw allow 6001- open this port
Worked for me!!!! Thank you very much.
Also when following the blogpost from Alex Bouma (referenced in the official docs) for setting laravel-websockets up with forge make sure you define the env variable LARAVEL_WEBSOCKETS_PORT
It defaults to 6001 but in the blogpost Alex uses 6002. So on production the env variable would be 6002.
Hello there, I want to know how can we use laravel-websockets with React Native. How do I config my project? Do I need to install pusher-js on the client-side?