Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: include AP handshake in 5s timeout #1458

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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
Loading