diff --git a/services/tunnelbroker/src/amqp.rs b/services/tunnelbroker/src/amqp.rs --- a/services/tunnelbroker/src/amqp.rs +++ b/services/tunnelbroker/src/amqp.rs @@ -85,7 +85,10 @@ async fn new() -> Result { let conn = create_connection().await?; conn.on_error(|err| { - // TODO: we should filter out some IOErrors here to avoid spamming alerts + if should_ignore_error(&err) { + debug!("Ignored AMQP Lapin error: {err:?}"); + return; + } error!(errorType = error_types::AMQP_ERROR, "Lapin error: {err:?}"); }); @@ -218,6 +221,26 @@ } } +fn should_ignore_error(err: &lapin::Error) -> bool { + use lapin::Error as E; + use std::io::ErrorKind; + + if is_connection_error(err) { + return true; + } + + if let E::IOError(io_error) = err { + return match io_error.kind() { + // Suppresses: "Socket was readable but we read 0."" + // We handle this by auto-reconnecting + ErrorKind::ConnectionAborted => true, + _ => false, + }; + } + + false +} + pub fn is_connection_error(err: &lapin::Error) -> bool { matches!( err,