[SNMP4J] Timeout issue with snmp4j-2.3.4.jar

Mark Ponthier mponthier at firescope.com
Tue Apr 16 18:55:02 CEST 2019


I have a program that does an SNMP GET every second against a network device using SNMPv3. It is random, but after around a thousand or so requests, it times out, and then it starts working again. Regardless of the specified timeout or the number of retries, it waits the entire time period and then returns a null response PDU. If I have a timeout of 1000ms and retries of 1, it will timeout after 2sec. If I have a timeout of 20000ms and retries of 1, it will timeout after 40sec. So the amount of the timeout is not the issue here. When it decides to timeout it will do so regardless if I wait 2 seconds or 40 seconds. The typical response time is usually 5-10ms. I'm wondering if this is normal behavior, an issue in the library, or if I just have something wrong in my code (see below). Less frequently this is also a problem with SNMPv2. I really appreciate any help or ideas you may have!


OctetString localEngineId = new OctetString(MPv3.createLocalEngineID());
USM usm = new USM(SecurityProtocols.getInstance(), localEngineId, 0);
SecurityModels.getInstance().addSecurityModel(usm);

String oid = "1.3.6.1.2.1.1.1.0";
PDU result = new ScopedPDU();
result.setType(PDU.GET);
result.add(new VariableBinding(new OID(oid)));
Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
usm.addUser(securityNameOctet, new UsmUser(securityNameOctet, authProtocol, new OctetString(authPassPhrase), privProtocol, new OctetString(privPassPhrase)));
snmp.listen();

String addrStr = "10.0.22.33/161";
Address targetAddress = GenericAddress.parse(addrStr);

UserTarget userTarget = new UserTarget();
userTarget.setAddress(targetAddress);
userTarget.setRetries(numRetries);
userTarget.setTimeout(timeout);
userTarget.setVersion(SnmpConstants.version3);
userTarget.setSecurityName(new OctetString(securityName));
userTarget.setSecurityLevel(SecurityLevel.AUTH_PRIV);

ResponseEvent responseEvent = snmp.send(pdu, target);
PDU responsePDU = responseEvent.getResponse();

if (responsePDU == null) {
LOGGER.error(;
LOGGER.error("SNMP GET timed out: addrStr[" + addrStr + "], oid[" + oid + "]");
}



Mark Ponthier | Senior Vice President, Engineering

www.firescope.com<http://www.firescope.com/> | Office: 214.296.9243 x451 | Mobile: 214.578.3676


More information about the SNMP4J mailing list