fix: increase SNMP timeout to 60s for SNMPv3 operations

SNMPv3 has significant encryption and authentication overhead compared to
v2c. MikroTik enterprise tree walks (1.3.6.1.4.1.14988) can take 16+
seconds with SNMPv3, causing timeouts with the previous 30s limit.

Increased timeout from 30s to 60s in both client.rs and device_poller.rs
to accommodate SNMPv3's additional latency.
This commit is contained in:
Graham McIntire 2026-02-05 08:45:20 -06:00
parent c62330bf40
commit 357d1711be
No known key found for this signature in database
2 changed files with 15 additions and 36 deletions

View file

@ -3,9 +3,10 @@ use crate::secret::SecretString;
use snmp2::SyncSession; use snmp2::SyncSession;
use std::time::Duration; use std::time::Duration;
// SNMP timeout in seconds - increased from 5s to 30s to match Phoenix app // SNMP timeout in seconds - increased to 60s for SNMPv3 operations
// and reduce timeouts for slow devices or congested networks // SNMPv3 has significant encryption/auth overhead, especially for large walks
const SNMP_TIMEOUT_SECS: u64 = 30; // MikroTik enterprise tree (1.3.6.1.4.1.14988) can take 16+ seconds with v3
const SNMP_TIMEOUT_SECS: u64 = 60;
/// SNMPv3 configuration bundle /// SNMPv3 configuration bundle
#[derive(Clone)] #[derive(Clone)]

View file

@ -6,7 +6,9 @@ use std::str::FromStr;
use std::time::Duration; use std::time::Duration;
use tokio::sync::{mpsc, oneshot}; use tokio::sync::{mpsc, oneshot};
const SNMP_TIMEOUT_SECS: u64 = 30; // SNMP timeout in seconds - increased to 60s for SNMPv3 operations
// SNMPv3 has significant encryption/auth overhead
const SNMP_TIMEOUT_SECS: u64 = 60;
/// Request to perform an SNMP operation /// Request to perform an SNMP operation
#[derive(Debug)] #[derive(Debug)]
@ -487,10 +489,7 @@ mod tests {
fn test_parse_auth_protocol_standard() { fn test_parse_auth_protocol_standard() {
use snmp2::v3::AuthProtocol; use snmp2::v3::AuthProtocol;
assert!(matches!(parse_auth_protocol("MD5"), Ok(AuthProtocol::Md5))); assert!(matches!(parse_auth_protocol("MD5"), Ok(AuthProtocol::Md5)));
assert!(matches!( assert!(matches!(parse_auth_protocol("SHA"), Ok(AuthProtocol::Sha1)));
parse_auth_protocol("SHA"),
Ok(AuthProtocol::Sha1)
));
assert!(matches!( assert!(matches!(
parse_auth_protocol("SHA1"), parse_auth_protocol("SHA1"),
Ok(AuthProtocol::Sha1) Ok(AuthProtocol::Sha1)
@ -541,10 +540,7 @@ mod tests {
parse_auth_protocol("sha-256"), parse_auth_protocol("sha-256"),
Ok(AuthProtocol::Sha256) Ok(AuthProtocol::Sha256)
)); ));
assert!(matches!( assert!(matches!(parse_auth_protocol("md5"), Ok(AuthProtocol::Md5)));
parse_auth_protocol("md5"),
Ok(AuthProtocol::Md5)
));
} }
#[test] #[test]
@ -557,35 +553,17 @@ mod tests {
use snmp2::v3::Cipher; use snmp2::v3::Cipher;
assert!(matches!(parse_priv_protocol("DES"), Ok(Cipher::Des))); assert!(matches!(parse_priv_protocol("DES"), Ok(Cipher::Des)));
assert!(matches!(parse_priv_protocol("AES"), Ok(Cipher::Aes128))); assert!(matches!(parse_priv_protocol("AES"), Ok(Cipher::Aes128)));
assert!(matches!( assert!(matches!(parse_priv_protocol("AES128"), Ok(Cipher::Aes128)));
parse_priv_protocol("AES128"), assert!(matches!(parse_priv_protocol("AES192"), Ok(Cipher::Aes192)));
Ok(Cipher::Aes128) assert!(matches!(parse_priv_protocol("AES256"), Ok(Cipher::Aes256)));
));
assert!(matches!(
parse_priv_protocol("AES192"),
Ok(Cipher::Aes192)
));
assert!(matches!(
parse_priv_protocol("AES256"),
Ok(Cipher::Aes256)
));
} }
#[test] #[test]
fn test_parse_priv_protocol_hyphenated() { fn test_parse_priv_protocol_hyphenated() {
use snmp2::v3::Cipher; use snmp2::v3::Cipher;
assert!(matches!( assert!(matches!(parse_priv_protocol("AES-128"), Ok(Cipher::Aes128)));
parse_priv_protocol("AES-128"), assert!(matches!(parse_priv_protocol("AES-192"), Ok(Cipher::Aes192)));
Ok(Cipher::Aes128) assert!(matches!(parse_priv_protocol("AES-256"), Ok(Cipher::Aes256)));
));
assert!(matches!(
parse_priv_protocol("AES-192"),
Ok(Cipher::Aes192)
));
assert!(matches!(
parse_priv_protocol("AES-256"),
Ok(Cipher::Aes256)
));
assert!(matches!( assert!(matches!(
parse_priv_protocol("AES-256-C"), parse_priv_protocol("AES-256-C"),
Ok(Cipher::Aes256) Ok(Cipher::Aes256)