Skip to content

Commit

Permalink
core: include AP handshake in 5s timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
kingosticks committed Jan 25, 2025
1 parent 98e9703 commit 03ae423
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions core/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ impl From<APLoginFailed> for AuthenticationError {
}

pub async fn connect(host: &str, port: u16, proxy: Option<&Url>) -> io::Result<Transport> {
const TIMEOUT: Duration = Duration::from_secs(3);
let socket = tokio::time::timeout(TIMEOUT, crate::socket::connect(host, port, proxy)).await??;

handshake(socket).await
const TIMEOUT: Duration = Duration::from_secs(5);
tokio::time::timeout(TIMEOUT, {
let socket = crate::socket::connect(host, port, proxy).await?;
debug!("Connection to AP established.");
handshake(socket)
})
.await?
}

pub async fn connect_with_retry(
Expand All @@ -80,7 +83,7 @@ pub async fn connect_with_retry(
match connect(host, port, proxy).await {
Ok(f) => return Ok(f),
Err(e) => {
debug!("Connection failed: {e}");
debug!("Connection to \"{host}:{port}\" failed: {e}");
if num_retries < max_retries {
num_retries += 1;
debug!("Retry access point...");
Expand Down

0 comments on commit 03ae423

Please sign in to comment.