Skip to content

Commit c1ae860

Browse files
authored
core: include AP handshake in 5s timeout (#1458)
* core: include AP handshake in 5s timeout * Update CHANGELOG.md
1 parent 98e9703 commit c1ae860

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- [core] MSRV is now 1.81 (breaking)
13+
- [core] AP connect and handshake have a combined 5 second timeout.
1314
- [connect] Replaced `ConnectConfig` with `ConnectStateConfig` (breaking)
1415
- [connect] Replaced `playing_track_index` field of `SpircLoadCommand` with `playing_track` (breaking)
1516
- [connect] Replaced Mercury usage in `Spirc` with Dealer

core/src/connection/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,13 @@ impl From<APLoginFailed> for AuthenticationError {
6363
}
6464

6565
pub async fn connect(host: &str, port: u16, proxy: Option<&Url>) -> io::Result<Transport> {
66-
const TIMEOUT: Duration = Duration::from_secs(3);
67-
let socket = tokio::time::timeout(TIMEOUT, crate::socket::connect(host, port, proxy)).await??;
68-
69-
handshake(socket).await
66+
const TIMEOUT: Duration = Duration::from_secs(5);
67+
tokio::time::timeout(TIMEOUT, {
68+
let socket = crate::socket::connect(host, port, proxy).await?;
69+
debug!("Connection to AP established.");
70+
handshake(socket)
71+
})
72+
.await?
7073
}
7174

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

0 commit comments

Comments
 (0)