I am using SNMP4j 1.11.3 in an application which runs SNMP manager and as well receiver concurrently. In this scenario when Java process starts, V3 trap receiver is working fine loading all the v3 users from the configuration, but once SNMP v3 manager starts making get/set requests to the devices the trap receiver stop receiving traps and says "RFC3414 ยง3.2.4 Unknown security name" when it tries to decrypt v3 traps.
As it seems the snmp4j is using a singleton SecurityModels in which it keeps the USM users collection, so when manager creates a new snmp session and addusmuser it is clearing the trap USM users, which is why trap receiver is not able to process the traps.
Initialization of the SNMP manager request code is as follows
Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
USM usm = new USM(SecurityProtocols.getInstance(),
new OctetString(MPv3.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(usm);
snmp.getUSM().addUser(securityName, new UsmUser(securityName,
authProtocol,
authPassphrase,
privProtocol,
privPassphrase));
How could I avoid this problem, What am I missing ??
FYI Manager and Receiver running on different threads.
Cheers, Reddy.