From 03ae4237405e8ab161cc6e705fd05d2df3032294 Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Fri, 24 Jan 2025 18:30:48 +0000 Subject: [PATCH 1/2] core: include AP handshake in 5s timeout --- core/src/connection/mod.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/src/connection/mod.rs b/core/src/connection/mod.rs index 6f2c7d440..ca89e87ba 100644 --- a/core/src/connection/mod.rs +++ b/core/src/connection/mod.rs @@ -63,10 +63,13 @@ impl From for AuthenticationError { } pub async fn connect(host: &str, port: u16, proxy: Option<&Url>) -> io::Result { - 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( @@ -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..."); From 24abeb259b386e90d826d89fcd9ebc6c54e296cf Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Mon, 27 Jan 2025 10:38:37 +0000 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 305bf5d5a..e8db0b46e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - [core] MSRV is now 1.81 (breaking) +- [core] AP connect and handshake have a combined 5 second timeout. - [connect] Replaced `ConnectConfig` with `ConnectStateConfig` (breaking) - [connect] Replaced `playing_track_index` field of `SpircLoadCommand` with `playing_track` (breaking) - [connect] Replaced Mercury usage in `Spirc` with Dealer