[SNMP4J] Please help me

Vee realvee2000 at yahoo.com
Wed Apr 7 11:15:10 CEST 2004


Hello
 
       I just happened to use SNMP4j and experienced some problem. My code is absolutely simple for the test of trying to get some value from device.
 
I firstly set the TransportMapping object due to constructor method of the Snmp class. (but actually I use only SNMP v.1 . I recognize that the Transport mapping is defined in SNMP 2, isn't it?)
 
        TransportMapping transport = new DefaultUdpTransportMapping();
        Snmp protocol = new Snmp(transport);
 
Hence, I put "transport.listen()" in it (I don't know the point to do this because...well as I said, I think that SNMP v.1 doesn't have transport mapping...if I'm incorrect please suggest) and then set the Target for my device.

        transport.listen();

        CommunityTarget myTarget = new CommunityTarget();
        Address deviceAdd;
        deviceAdd = GenericAddress.parse("udp:10.201.0.110/161");

        myTarget.setAddress(deviceAdd);
        myTarget.setCommunity(new OctetString("public"));
        myTarget.setRetries(0);
        myTarget.setTimeout(5*60);    
        myTarget.setVersion(SnmpConstants.version1);
        
and then, I'm ready to submit the PDU to device. Note that the OID I want to get is ifInOctets which is 1.3.6.1.2.1.2.2.1.10 according to the MIB-2 RFC1213

        PDU pdu = new PDUv1();
        VariableBinding var = new VariableBinding(new OID("1.3.6.1.2.1.2.2.1.10"));
        pdu.add(var);
        pdu.setType(PDU.GET);
        pdu = protocol.sendPDU(pdu,myTarget);
 
and the result, it said the null is returned from .sendPDU
I don't know what I have done wrong. So I try to use log4j and here is the debug messages.
 
DEBUG [main] - Initialized Salt to 9c1ccd88a79fbc33.
DEBUG [main] - Sending message to 10.201.0.110/161 with length 44: 30:2a:02:01:00:04:06:70:75:62:6c:69:63:a1:1d:02:04:08:73:35:b7:02:01:00:02:01:00:30:0f:30:0d:06:09:2b:06:01:02:01:02:02:01:0a:05:00
DEBUG [main] - New pending request with handleorg.snmp4j.mp.PduHandle at 87335b7
DEBUG [Thread-1] - Received message from /10.201.0.110 with length 13: 30:82:00:34:02:01:00:04:06:70:75:62:6c

ERROR [Thread-1] - java.io.IOException: The encoded length 52 exceeds the number of bytes left in input at position 4

java.io.IOException: The encoded length 52 exceeds the number of bytes left in input at position 4
        at org.snmp4j.asn1.BER.checkLength(BER.java:805)
        at org.snmp4j.asn1.BER.decodeLength(BER.java:489)
        at org.snmp4j.asn1.BER.decodeHeader(BER.java:522)
        at org.snmp4j.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.java:240)
        at org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:163)
java.lang.NullPointerException

 
It said "the encoded length 52 exceeds the number of bytes left in input at position 4"  
 
what is this??   Could you give me any suggestion?  Do I need to do any extra work to make it run properly?? (such as addCommandResponder)
 
Thank you so much
 
Regards,
Jacky
 
 
 
 


Surmsak Mahittivanitcha [V] 
Address : 71/398 Pitt st. Sydney, NSW  2000
Mob. : +61(4)-2165-5794



---------------------------------
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway - Enter today
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://oosnmp.net/pipermail/snmp4j/attachments/20040407/5cc4898f/attachment.html>


More information about the SNMP4J mailing list