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

@@ -11,4 +11,46 @@
<main class="pb-10 main max-w-screen-2xl">
{{ $slot }}
</main>
<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
</script>
@endsection

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;

View File

@@ -12,7 +12,7 @@
<div
class="scrollbar flex flex-col-reverse w-full overflow-y-auto border border-solid rounded border-coolgray-300 max-h-[32rem] p-4 pt-6 text-xs text-white">
<pre class="font-mono whitespace-pre-wrap" @if ($isPollingActive) wire:poll.2000ms="polling" @endif>{{ RunRemoteProcess::decodeOutput($this->activity) }}</pre>
<pre class="font-mono whitespace-pre-wrap" @if ($isPollingActive) wire:poll.1000ms="polling" @endif>{{ RunRemoteProcess::decodeOutput($this->activity) }}</pre>
</div>
@endif
</div>