Skip to content

Commit

Permalink
fix: attempt to fix redis connection error
Browse files Browse the repository at this point in the history
  • Loading branch information
wajeht committed Sep 17, 2022
1 parent 2ecc7d3 commit c69824e
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/utils/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,34 @@ import Redis from 'ioredis';
import logger from './logger.js';
import Chad from './chad.js';

const client = new Redis({
port: REDIS.port, // Redis port
host: REDIS.host, // Redis host
username: REDIS.username, // needs Redis >= 6
const redisConfig = {
port: REDIS.port,
host: REDIS.host,
username: REDIS.username,
password: REDIS.password,
db: REDIS.db, // Defaults to 0
});
db: REDIS.db,
autoResubscribe: false,
lazyConnect: true,
maxRetriesPerRequest: 0,
};

client.on('error', (error) => {
let client;

try {
client = new Redis(redisConfig);
logger.info(`Redis client started`);
} catch (e) {
logger.error(e);
Chad.flex(e.message, e.stack);
});
}

client.on('connect', (error) => {
logger.info(`Redis client started`);
});
// client.on('error', (error) => {
// logger.error(e);
// Chad.flex(e.message, e.stack);
// });

// client.on('connect', (error) => {
// logger.info(`Redis client started`);
// });

export default client;

0 comments on commit c69824e

Please sign in to comment.