From 470ee7e4498a91e9554268ea7f0364e0a0dc9449 Mon Sep 17 00:00:00 2001 From: anishshobithps Date: Wed, 8 May 2024 14:00:38 +0530 Subject: [PATCH] fix: redis, connection issues and handle the error --- src/lib/redis.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/redis.ts b/src/lib/redis.ts index ca64790..83ad528 100644 --- a/src/lib/redis.ts +++ b/src/lib/redis.ts @@ -2,6 +2,8 @@ import IORedis, { RedisOptions } from 'ioredis'; const options: RedisOptions = { maxRetriesPerRequest: null, + connectTimeout: 10000, + keepAlive: 1000, tls: { rejectUnauthorized: false, } @@ -11,4 +13,8 @@ export const connection = new IORedis(process.env.REDIS_KV!, options); connection.once("connect", () => { console.log('Connected to Redis'); -}); \ No newline at end of file +}); + +connection.on("error", (error) => { + console.error('Redis error:', error); +});