Skip to content

Commit

Permalink
Refactored get() method in SnmpSession class to make request even if …
Browse files Browse the repository at this point in the history
…authEngineID cannot be discovered
  • Loading branch information
dmccoystephenson committed May 9, 2024
1 parent be02856 commit 3822a69
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,23 @@ public ResponseEvent set(PDU pdu, Snmp snmpob, UserTarget targetob, Boolean keep
// Try to send the SNMP request (synchronously)
ResponseEvent responseEvent = null;
try {
// discover auth engine ID
byte[] authEngineID = snmpob.discoverAuthoritativeEngineID(targetob.getAddress(), 1000);
if (authEngineID != null && authEngineID.length > 0) {
targetob.setAuthoritativeEngineID(authEngineID);
}
if (authEngineID != null) {
responseEvent = snmpob.set(pdu, targetob);
if (!keepOpen) {
snmpob.close();
}
} else {
if (authEngineID == null) {
problems.add("Failed to discover authoritative engine ID");
}

// make request
responseEvent = snmpob.set(pdu, targetob);
if (!keepOpen) {
snmpob.close();
}
} catch (IOException e) {
if (!problems.isEmpty()) {
logger.error("Problems sending TIM to RSU {}: {}", targetob.getAddress(), problems.stream().collect(Collectors.joining(", ")));
logger.error("Problems sending TIM to RSU {}: {}", targetob.getAddress(), problems.stream().collect(Collectors.joining(" | ")));
}
throw new IOException("Failed to send SNMP request: " + e);
}
Expand Down

0 comments on commit 3822a69

Please sign in to comment.