core: HTTPClient: update socket should just automatically retry on subsqeuent auth success
This commit is contained in:
@@ -426,6 +426,7 @@ impl<K: AuthenticationStore + Send + Sync> APIInterface for HTTPAPIClient<K> {
|
||||
|
||||
log::debug!("Websocket request: {:?}", request);
|
||||
|
||||
let mut should_retry = true; // retry once after authenticating.
|
||||
match connect_async(request).await.map_err(Error::from) {
|
||||
Ok((socket, response)) => {
|
||||
log::debug!("Websocket connected: {:?}", response.status());
|
||||
@@ -440,8 +441,12 @@ impl<K: AuthenticationStore + Send + Sync> APIInterface for HTTPAPIClient<K> {
|
||||
let new_token = self.authenticate(credentials.clone()).await?;
|
||||
self.auth_store.set_token(new_token.to_string()).await;
|
||||
|
||||
if should_retry {
|
||||
// try again on the next attempt.
|
||||
continue;
|
||||
} else {
|
||||
break Err(e);
|
||||
}
|
||||
} else {
|
||||
log::error!("Websocket unauthorized, no credentials provided");
|
||||
break Err(Error::ClientError(
|
||||
|
||||
Reference in New Issue
Block a user