Skip to content

Commit cc934be

Browse files
committed
fix MOVED and ASK in TLS mode
1 parent 1a40b34 commit cc934be

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/cluster.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl ClusterConnection {
215215
if connections.is_empty() {
216216
return Err(RedisError::from((
217217
ErrorKind::IoError,
218-
"It is failed to check startup nodes.",
218+
"It failed to check startup nodes.",
219219
)));
220220
}
221221
Ok(connections)
@@ -430,15 +430,28 @@ impl ClusterConnection {
430430
let kind = err.kind();
431431

432432
if kind == ErrorKind::Ask {
433-
redirected = err.redirect_node().map(|x| format!("redis://{}", x.0));
433+
// TODO: clean up this copy pasta
434+
redirected = err.redirect_node().map(|(node, _slot)| {
435+
match self.tls {
436+
None => format!("redis://{}", node),
437+
Some(TlsMode::Insecure) => format!("rediss://{}/#insecure", node),
438+
Some(TlsMode::Secure) => format!("rediss://{}", node),
439+
}
440+
});
434441
is_asking = true;
435442
} else if kind == ErrorKind::Moved {
436443
// Refresh slots.
437444
self.refresh_slots()?;
438445
excludes.clear();
439446

440447
// Request again.
441-
redirected = err.redirect_node().map(|x| format!("redis://{}", x.0));
448+
redirected = err.redirect_node().map(|(node, _slot)| {
449+
match self.tls {
450+
None => format!("redis://{}", node),
451+
Some(TlsMode::Insecure) => format!("rediss://{}/#insecure", node),
452+
Some(TlsMode::Secure) => format!("rediss://{}", node),
453+
}
454+
});
442455
is_asking = false;
443456
continue;
444457
} else if kind == ErrorKind::TryAgain || kind == ErrorKind::ClusterDown {

0 commit comments

Comments
 (0)