Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🐙 fix: Add Redis Ping Interval to Prevent Connection Drops (#7127)

Petera6f0a8244f1a
diff --git a/api/cache/keyvRedis.js b/api/cache/keyvRedis.js
index 0c830422e1..cb9d837e21 100644
--- a/api/cache/keyvRedis.js
+++ b/api/cache/keyvRedis.js
@@ -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));