fix: keep-alive ws connections
This commit is contained in:
parent
fce1e34fc8
commit
08e4afbbc4
1 changed files with 16 additions and 0 deletions
|
|
@ -32,6 +32,22 @@ class="icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|||
let socket;
|
||||
let commandBuffer = '';
|
||||
|
||||
|
||||
function keepAlive() {
|
||||
if (socket && socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(JSON.stringify({
|
||||
ping: true
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
const keepAliveInterval = setInterval(keepAlive, 30000);
|
||||
|
||||
// Clear the interval when the component is destroyed
|
||||
document.addEventListener('livewire:navigating', () => {
|
||||
clearInterval(keepAliveInterval);
|
||||
});
|
||||
|
||||
function initializeWebSocket() {
|
||||
if (!socket || socket.readyState === WebSocket.CLOSED) {
|
||||
// Only use port if Coolify is used with ip (so it has a port in the url)
|
||||
|
|
|
|||
Loading…
Reference in a new issue