mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
🐙 fix: Add Redis Ping Interval to Prevent Connection Drops (#7127)
Co-authored-by: Peter Rothlaender <peter.rothlaender@ginkgo.com>
This commit is contained in:
parent
f04f8f53be
commit
a6f0a8244f
1 changed files with 7 additions and 0 deletions
7
api/cache/keyvRedis.js
vendored
7
api/cache/keyvRedis.js
vendored
|
@ -75,6 +75,12 @@ if (REDIS_URI && isEnabled(USE_REDIS)) {
|
|||
} else {
|
||||
keyvRedis = new KeyvRedis(REDIS_URI, keyvOpts);
|
||||
}
|
||||
|
||||
const pingInterval = setInterval(() => {
|
||||
logger.debug('KeyvRedis ping');
|
||||
keyvRedis.client.ping().catch(err => logger.error('Redis keep-alive ping failed:', err));
|
||||
}, 5 * 60 * 1000);
|
||||
|
||||
keyvRedis.on('ready', () => {
|
||||
logger.info('KeyvRedis connection ready');
|
||||
});
|
||||
|
@ -85,6 +91,7 @@ if (REDIS_URI && isEnabled(USE_REDIS)) {
|
|||
logger.info('KeyvRedis connection ended');
|
||||
});
|
||||
keyvRedis.on('close', () => {
|
||||
clearInterval(pingInterval);
|
||||
logger.info('KeyvRedis connection closed');
|
||||
});
|
||||
keyvRedis.on('error', (err) => logger.error('KeyvRedis connection error:', err));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue