Sep 14, 2023
2
Level 1
WebSocket is closed before the connection is established
Hello, i'm using Nuxt and Laravel Websockets and trying to start the connection, but i keep getting the error "WebSocket is closed before the connection is established", tried to change in diferent ways but i couldn't solve it.
It's beeing really hard to learn to use some of these features, i'm see a lack of tutorials and even the documentation is not so crystal for me, if you guys have any tips for me (junior laravel developer trying to learn the ecossystem in a solid way) i will be happy to take notes :)
ERROR MESSAGE
socket.js?t=1694724010678:10 WebSocket connection to 'wss://local.lo/app/root?protocol=7&client=js&version=8.3.0&flash=false' failed: WebSocket is closed before the connection is established.
This is my Nuxt Plugin
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
export default defineNuxtPlugin((nuxtApp) => {
if (process.client) {
window.Pusher = Pusher;
}
const echo = new Echo({
broadcaster: 'pusher',
key: 'root',
cluster: 'mt1',
wsHost: "local.lo", //this is the value in my system that i use for 127.0.0.1
wsPort: 6001,
disableStats: true,
forceTLS: true
});
return {
provide: {
echo: echo,
},
};
});
.ENV
PUSHER_APP_ID=laravel
PUSHER_APP_KEY=root
PUSHER_APP_SECRET=root
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
Broadcasting Config
'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'),
'encrypted' => true,
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'http'
],
],
Please or to participate in this conversation.