1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-03 17:59:24 +02:00

core: include AP handshake in 5s timeout (#1458)

* core: include AP handshake in 5s timeout

* Update CHANGELOG.md
This commit is contained in:
Nick Steel 2025-01-28 16:04:58 +00:00 committed by GitHub
parent 98e9703edb
commit c1ae8608aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View file

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- [core] MSRV is now 1.81 (breaking) - [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 `ConnectConfig` with `ConnectStateConfig` (breaking)
- [connect] Replaced `playing_track_index` field of `SpircLoadCommand` with `playing_track` (breaking) - [connect] Replaced `playing_track_index` field of `SpircLoadCommand` with `playing_track` (breaking)
- [connect] Replaced Mercury usage in `Spirc` with Dealer - [connect] Replaced Mercury usage in `Spirc` with Dealer

View file

@ -63,10 +63,13 @@ impl From<APLoginFailed> for AuthenticationError {
} }
pub async fn connect(host: &str, port: u16, proxy: Option<&Url>) -> io::Result<Transport> { pub async fn connect(host: &str, port: u16, proxy: Option<&Url>) -> io::Result<Transport> {
const TIMEOUT: Duration = Duration::from_secs(3); const TIMEOUT: Duration = Duration::from_secs(5);
let socket = tokio::time::timeout(TIMEOUT, crate::socket::connect(host, port, proxy)).await??; tokio::time::timeout(TIMEOUT, {
let socket = crate::socket::connect(host, port, proxy).await?;
handshake(socket).await debug!("Connection to AP established.");
handshake(socket)
})
.await?
} }
pub async fn connect_with_retry( pub async fn connect_with_retry(
@ -80,7 +83,7 @@ pub async fn connect_with_retry(
match connect(host, port, proxy).await { match connect(host, port, proxy).await {
Ok(f) => return Ok(f), Ok(f) => return Ok(f),
Err(e) => { Err(e) => {
debug!("Connection failed: {e}"); debug!("Connection to \"{host}:{port}\" failed: {e}");
if num_retries < max_retries { if num_retries < max_retries {
num_retries += 1; num_retries += 1;
debug!("Retry access point..."); debug!("Retry access point...");