fix: double ws connection

This commit is contained in:
Andras Bacsai
2023-12-08 22:51:42 +01:00
parent ba2e4c06f1
commit 6bb79e10bc
6 changed files with 53 additions and 44 deletions

View File

@@ -46,46 +46,6 @@
<x-version class="fixed left-2 bottom-1" />
<script data-navigate-once>
@auth
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'pusher',
cluster: "{{ env('PUSHER_HOST') }}" || window.location.hostname,
key: "{{ env('PUSHER_APP_KEY') }}" || 'coolify',
wsHost: "{{ env('PUSHER_HOST') }}" || window.location.hostname,
wsPort: "{{ env('PUSHER_PORT') }}" || 6001,
wssPort: "{{ env('PUSHER_PORT') }}" || 6001,
forceTLS: false,
encrypted: true,
enableStats: false,
enableLogging: true,
enabledTransports: ['ws', 'wss'],
});
if ("{{ auth()->user()->id }}" == 0) {
let checkPusherInterval = null;
let checkNumber = 0;
let errorMessage =
"Coolify could not connect to the new realtime service introduced in beta.154.<br>Please check the related <a href='https://coolify.io/docs/cloudflare-tunnels' target='_blank'>documentation</a> or get help on <a href='https://coollabs.io/discord' target='_blank'>Discord</a>.";
checkPusherInterval = setInterval(() => {
if (window.Echo) {
if (window.Echo.connector.pusher.connection.state !== 'connected') {
checkNumber++;
if (checkNumber > 5) {
clearInterval(checkPusherInterval);
Livewire.emit('error', errorMessage);
}
} else {
console.log('Coolify is now connected to the new realtime service introduced in beta.154.');
clearInterval(checkPusherInterval);
}
} else {
clearInterval(checkPusherInterval);
Livewire.emit('error', errorMessage);
}
}, 2000);
}
@endauth
let checkHealthInterval = null;
let checkIfIamDeadInterval = null;