Merge pull request #3234 from kefoster951/fix_redis_auth

Fix redis authentication reattempt issue
This commit is contained in:
Louis Lam 2023-06-27 15:21:30 +08:00 committed by GitHub
commit dd77baabe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -413,12 +413,18 @@ exports.radius = function (
exports.redisPingAsync = function (dsn) {
return new Promise((resolve, reject) => {
const client = redis.createClient({
url: dsn,
url: dsn
});
client.on("error", (err) => {
if (client.isOpen) {
client.disconnect();
}
reject(err);
});
client.connect().then(() => {
if (!client.isOpen) {
client.emit("error", new Error("connection isn't open"));
}
client.ping().then((res, err) => {
if (client.isOpen) {
client.disconnect();
@ -428,7 +434,7 @@ exports.redisPingAsync = function (dsn) {
} else {
resolve(res);
}
});
}).catch(error => reject(error));
});
});
};