mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-28 11:49:39 -05:00
avoid looping periphery client error
This commit is contained in:
@@ -39,17 +39,25 @@ pub async fn handler(
|
||||
|
||||
info!("Initiating outbound connection to {url}");
|
||||
|
||||
let mut already_logged_connection_error = false;
|
||||
let mut already_logged_login_error = false;
|
||||
|
||||
loop {
|
||||
let (socket, accept) =
|
||||
match connect_websocket(&core_endpoint).await {
|
||||
Ok(res) => res,
|
||||
Err(e) => {
|
||||
warn!("{e:#}");
|
||||
if !already_logged_connection_error {
|
||||
warn!("{e:#}");
|
||||
already_logged_connection_error = true;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
already_logged_connection_error = false;
|
||||
|
||||
info!("Connected to core connection websocket");
|
||||
|
||||
let connection_identifiers = ConnectionIdentifiers {
|
||||
@@ -64,10 +72,14 @@ pub async fn handler(
|
||||
connection_identifiers,
|
||||
"TEST",
|
||||
&mut write_receiver,
|
||||
|| already_logged_login_error = false,
|
||||
)
|
||||
.await
|
||||
{
|
||||
warn!("Failed to login | {e:#}");
|
||||
if !already_logged_login_error {
|
||||
warn!("Failed to login | {e:#}");
|
||||
already_logged_login_error = true;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -60,8 +60,10 @@ async fn handle_websocket<L: LoginFlow>(
|
||||
connection_identifiers: ConnectionIdentifiers<'_>,
|
||||
private_key: &str,
|
||||
write_receiver: &mut BufferedReceiver<Bytes>,
|
||||
mut on_login_success: impl FnMut(),
|
||||
) -> anyhow::Result<()> {
|
||||
L::login(&mut socket, connection_identifiers, private_key).await?;
|
||||
on_login_success();
|
||||
|
||||
info!("Logged in to core connection websocket");
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ async fn handler(
|
||||
connection_identifiers,
|
||||
"TEST",
|
||||
&mut write_receiver,
|
||||
|| {},
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user