[SNMP4J] strange exception

Imre Kovács imre.kov at gmail.com
Mon Feb 27 14:24:10 CET 2006


Hi everyone,



I wrote an agent application which listens for incoming PDUs, processes only
the GET/SET methods and uses the SNMPv3 security capabilities. To test it, I
use the Snmp4j.exe it is a really useful tool. Everything works fine, the
program throws the unsupported types and security levels, but if I use the
following parameters:

SNMP4J -c public -u Admin -r 0 -t 5000 -a MD5 -A goodpassword -x DES -P
badpassword -p GET 10.20.2.101/161 "1.3.6.1.4.1.5.5.2.0"

Where the authentication password is the same as in the application and the
privacy password is a wrong one. I get various types of exceptions, not from
my program, but from the package and I can't catch it.  I get one exception
at a time, but they are different every time. The application does not
freeze, it runs alive, but every time there is these messages in the
console. It is the only combination which causes this, if both passwords are
wrong or just the authentication one, there is no exception.



Examples of these messages:

java.io.IOException: The encoded length 57 exceeds the number of bytes left
in input at position 2 which actually is 48

        at org.snmp4j.asn1.BER.checkLength(BER.java:902)

        at org.snmp4j.asn1.BER.decodeLength(BER.java:547)

        at org.snmp4j.asn1.BER.decodeHeader(BER.java:584)

        at org.snmp4j.asn1.BER.decodeHeader(BER.java:609)

        at org.snmp4j.ScopedPDU.decodeBER(ScopedPDU.java:141)

        at org.snmp4j.mp.MPv3.prepareDataElements(MPv3.java:984)

        at org.snmp4j.MessageDispatcherImpl.dispatchMessage(
MessageDispatcherImpl.java:240)

        at org.snmp4j.MessageDispatcherImpl.processMessage(
MessageDispatcherImpl.java:323)

        at org.snmp4j.util.MultiThreadedMessageDispatcher$MessageTask.run(
MultiThreadedMessageDispatcher.java:190)

        at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:236)

java.io.IOException: Cannot process extension IDs at position 1

        at org.snmp4j.asn1.BER.decodeHeader(BER.java:580)

        at org.snmp4j.asn1.BER.decodeHeader(BER.java:609)

        at org.snmp4j.ScopedPDU.decodeBER(ScopedPDU.java:141)

        at org.snmp4j.mp.MPv3.prepareDataElements(MPv3.java:984)

        at org.snmp4j.MessageDispatcherImpl.dispatchMessage(
MessageDispatcherImpl.java:240)

        at org.snmp4j.MessageDispatcherImpl.processMessage(
MessageDispatcherImpl.java:323)

        at org.snmp4j.util.MultiThreadedMessageDispatcher$MessageTask.run(
MultiThreadedMessageDispatcher.java:190)

        at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:236)

java.io.IOException: Wrong ASN.1 type. Not a string: 91 at position 3

        at org.snmp4j.asn1.BER.decodeString(BER.java:704)

        at org.snmp4j.smi.OctetString.decodeBER(OctetString.java:151)

        at org.snmp4j.ScopedPDU.decodeBER(ScopedPDU.java:143)

        at org.snmp4j.mp.MPv3.prepareDataElements(MPv3.java:984)

        at org.snmp4j.MessageDispatcherImpl.dispatchMessage(
MessageDispatcherImpl.java:240)

        at org.snmp4j.MessageDispatcherImpl.processMessage(
MessageDispatcherImpl.java:323)

        at org.snmp4j.util.MultiThreadedMessageDispatcher$MessageTask.run(
MultiThreadedMessageDispatcher.java:190)

        at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:236)

java.io.IOException: The encoded length 96 exceeds the number of bytes left
in input at position 2 which actually is 48

        at org.snmp4j.asn1.BER.checkLength(BER.java:902)

        at org.snmp4j.asn1.BER.decodeLength(BER.java:547)

        at org.snmp4j.asn1.BER.decodeHeader(BER.java:584)

        at org.snmp4j.asn1.BER.decodeHeader(BER.java:609)

        at org.snmp4j.ScopedPDU.decodeBER(ScopedPDU.java:141)

        at org.snmp4j.mp.MPv3.prepareDataElements(MPv3.java:984)

        at org.snmp4j.MessageDispatcherImpl.dispatchMessage(
MessageDispatcherImpl.java:240)

        at org.snmp4j.MessageDispatcherImpl.processMessage(
MessageDispatcherImpl.java:323)

        at org.snmp4j.util.MultiThreadedMessageDispatcher$MessageTask.run(
MultiThreadedMessageDispatcher.java:190)

        at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:236)

The code of my application is a bit too long to copy here, but as you see,
there is no reference out of the snmp4j package. I use the ThreadPool and
MultiThreadedMessageDispatcher classes to have more thread working on the
incoming messages. I initialized them this way :

threadPool = ThreadPool.create("DispatcherPool", 2);
mtDispatcher = new MultiThreadedMessageDispatcher(threadPool, new
MessageDispatcherImpl());

mtDispatcher.addMessageProcessingModel(new MPv3());
mtDispatcher.addMessageProcessingModel(new MPv2c());
mtDispatcher.addMessageProcessingModel(new MPv1());

snmp = new Snmp(mtDispatcher, transport);

Has anyone an idea what did I wrong? The final version of my program won't
use the console, and will work fine even with this exception, but is is a
little embarassing.

Thanks for the help in advance!

Regards
--
Imre Kovacs, Hungary



More information about the SNMP4J mailing list