我关闭了redis以检查errhandle,但它不断重新连接
const redis = new Redis(
Object.assign({}, config.redis.server, {
retryStrategy(times) {
return Math.min(times * 100, 3000);
}
})
)
redis.on('error', err => {
console.log(`redis error:${err.toString()}`);
});
错误消息日志:
redis error:Error: connect ECONNREFUSED 127.0.0.1:6379
代码解决了此问题:
const redis = new Redis(
Object.assign({}, config.redis.server, {
retryStrategy(times) {
if (times > 10) { // reconnect over 10 times closed
return false;
}
return Math.min(times * 100, 3000);
}
})
)