Private
Public Access
1
0

core: HTTPClient: event stream should just automatically retry after auth token

This commit is contained in:
2025-09-09 13:30:53 -07:00
parent 469fd8fa13
commit 4db28222a6

View File

@@ -397,6 +397,7 @@ impl<K: AuthenticationStore + Send + Sync> APIInterface for HTTPAPIClient<K> {
let uri = self
.uri_for_endpoint(&endpoint, Some(self.websocket_scheme()))?;
loop {
log::debug!("Connecting to websocket: {:?}", uri);
let auth = self.auth_store.get_token().await;
@@ -428,7 +429,7 @@ impl<K: AuthenticationStore + Send + Sync> APIInterface for HTTPAPIClient<K> {
match connect_async(request).await.map_err(Error::from) {
Ok((socket, response)) => {
log::debug!("Websocket connected: {:?}", response.status());
Ok(WebsocketEventSocket::new(socket))
break Ok(WebsocketEventSocket::new(socket))
}
Err(e) => match &e {
Error::ClientError(ce) => match ce.as_str() {
@@ -440,21 +441,22 @@ impl<K: AuthenticationStore + Send + Sync> APIInterface for HTTPAPIClient<K> {
self.auth_store.set_token(new_token.to_string()).await;
// try again on the next attempt.
return Err(Error::Unauthorized);
continue;
} else {
log::error!("Websocket unauthorized, no credentials provided");
return Err(Error::ClientError(
break Err(Error::ClientError(
"Unauthorized, no credentials provided".into(),
));
}
}
_ => Err(e),
_ => break Err(e),
},
_ => Err(e),
_ => break Err(e),
},
}
}
}
}
impl<K: AuthenticationStore + Send + Sync> HTTPAPIClient<K> {