Skip to content

Commit

Permalink
Apply a hardcoded tiemout of 10 seconds to connection attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHecart committed Dec 11, 2024
1 parent df86f75 commit 7921463
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions zenoh/src/net/runtime/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const RCV_BUF_SIZE: usize = u16::MAX as usize;
const SCOUT_INITIAL_PERIOD: Duration = Duration::from_millis(1_000);
const SCOUT_MAX_PERIOD: Duration = Duration::from_millis(8_000);
const SCOUT_PERIOD_INCREASE_FACTOR: u32 = 2;
const CONNECTION_TIMEOUT: Duration = Duration::from_millis(10_000);

pub enum Loop {
Continue,
Expand Down Expand Up @@ -350,7 +351,7 @@ impl Runtime {
if retry_config.timeout().is_zero() || self.get_global_connect_timeout().is_zero() {
// try to connect and exit immediately without retry
if self
.peer_connector(endpoint, retry_config.timeout())
.peer_connector(endpoint, CONNECTION_TIMEOUT)
.await
.is_ok()
{
Expand Down Expand Up @@ -379,7 +380,7 @@ impl Runtime {
);
if retry_config.timeout().is_zero() || self.get_global_connect_timeout().is_zero() {
// try to connect and exit immediately without retry
if let Err(e) = self.peer_connector(endpoint, retry_config.timeout()).await {
if let Err(e) = self.peer_connector(endpoint, CONNECTION_TIMEOUT).await {
if retry_config.exit_on_failure {
return Err(e);
}
Expand Down Expand Up @@ -795,7 +796,7 @@ impl Runtime {
tracing::trace!("Trying to connect to configured peer {}", peer);
let endpoint = peer.clone();
tokio::select! {
res = tokio::time::timeout(retry_config.timeout(), self.manager().open_transport_unicast(endpoint)) => {
res = tokio::time::timeout(CONNECTION_TIMEOUT, self.manager().open_transport_unicast(endpoint)) => {
match res {
Ok(Ok(transport)) => {
tracing::debug!("Successfully connected to configured peer {}", peer);
Expand Down Expand Up @@ -977,7 +978,6 @@ impl Runtime {
};

let endpoint = locator.to_owned().into();
let retry_config = self.get_connect_retry_config(&endpoint);
let priorities = locator
.metadata()
.get(Metadata::PRIORITIES)
Expand All @@ -998,7 +998,7 @@ impl Runtime {
{
if is_multicast {
match tokio::time::timeout(
retry_config.timeout(),
CONNECTION_TIMEOUT,
manager.open_transport_multicast(endpoint),
)
.await
Expand All @@ -1014,7 +1014,7 @@ impl Runtime {
}
} else {
match tokio::time::timeout(
retry_config.timeout(),
CONNECTION_TIMEOUT,
manager.open_transport_unicast(endpoint),
)
.await
Expand Down

0 comments on commit 7921463

Please sign in to comment.