Fix orphan database connections resulting in an inability to connect to databases. #5567

This commit is contained in:
Khushboo Vashi
2023-01-19 15:57:02 +05:30
committed by GitHub
parent 22cc658dca
commit 6ae91592d1
10 changed files with 190 additions and 7 deletions

View File

@@ -0,0 +1,31 @@
/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2023, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import gettext from 'sources/gettext';
import url_for from 'sources/url_for';
import getApiInstance from '../../../static/js/api_instance';
import Notifier from '../../../static/js/helpers/Notifier';
import pgAdmin from 'sources/pgadmin';
const axiosApi = getApiInstance();
let HEARTBEAT_TIMEOUT = pgAdmin.heartbeat_timeout * 1000;
export function send_heartbeat(_server_id) {
// Send heartbeat to the server every 30 seconds
setInterval(function() {
axiosApi.post(url_for('misc.heartbeat'), {'sid': _server_id})
.then(() => {
// pass
})
.catch((error) => {
Notifier.error(gettext(`pgAdmin server not responding, try to login again: ${error.message || error.response.data.errormsg}`));
});
}, HEARTBEAT_TIMEOUT);
}