How do I stop my snmp4j USM users from overwrighting at runtime?

19 Views Asked by At

I have two java classes, lets call them Manager-1 and Manager-2, that both use snmp4j to manage some switches. Manager-1 is in the source code of the current project I am working in, but Manager-2 is imported from a library.

Both classes have been run independently, and can be seen communicating and performing snmp actions on their relevant switches. However when they are run at the same time I am seeing MessageException: Message processing model 3 returned error: Unknown security name.

I've managed to identify that the issue comes from both Manager-1 and Manager-2 using their own instances of USM but I am unsure how to fix the issue.

I added some debug print outs into a scheduled snmpGet function and can see at runtime Manager-1 is correctly adding the user to the usm when performing its first operation, as seen with: System.out.println("DEBUG: " + mySnmp.getUSM().getUserTable().getUserEntries());

I added the same printout into Manager-2 and see that it is correctly adding its users to its own USM, however when Manager-1 performs its next scheduled snmp operation I can see that it's USM users are now populated with Manager-2's users and not the ones defined by Manager-1.

I am not overly familiar with snmp4j so if anyone knows what I'm missing I'd appreciate the help.

0

There are 0 best solutions below