Retry DNS resolution on failure (#1762)
Otherwise, a transient DNS failure makes the node hang.
This commit is contained in:
parent
86169f6412
commit
579bd4a368
|
|
@ -38,6 +38,8 @@ impl Config {
|
||||||
/// If DNS resolution fails or times out for all peers, returns an empty list.
|
/// If DNS resolution fails or times out for all peers, returns an empty list.
|
||||||
async fn parse_peers(peers: &HashSet<String>) -> HashSet<SocketAddr> {
|
async fn parse_peers(peers: &HashSet<String>) -> HashSet<SocketAddr> {
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
|
|
||||||
|
loop {
|
||||||
let peer_addresses = peers
|
let peer_addresses = peers
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| Config::resolve_host(s))
|
.map(|s| Config::resolve_host(s))
|
||||||
|
|
@ -46,13 +48,17 @@ impl Config {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if peer_addresses.is_empty() {
|
if peer_addresses.is_empty() {
|
||||||
tracing::warn!(
|
tracing::info!(
|
||||||
?peers,
|
?peers,
|
||||||
?peer_addresses,
|
?peer_addresses,
|
||||||
"empty peer list after DNS resolution"
|
"empty peer list after DNS resolution, retrying after {} seconds",
|
||||||
|
crate::constants::DNS_LOOKUP_TIMEOUT.as_secs()
|
||||||
);
|
);
|
||||||
};
|
tokio::time::sleep(crate::constants::DNS_LOOKUP_TIMEOUT).await;
|
||||||
peer_addresses
|
} else {
|
||||||
|
return peer_addresses;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the initial seed peers based on the configured network.
|
/// Get the initial seed peers based on the configured network.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue