[SNMP4J] Snmp v2 invalid community string

gangadhar katakam gangadhar.katakam at yahoo.com
Thu Dec 2 11:03:37 CET 2010


Hi,

I have written sample to code to fetch data from switch using snmp v2 community 
string. I gave correct community string, i am able to get the data but if i give 
wrong community string, i am not getting proper error. is it an expected 
behavior?

I am expecting either an exception or response with invalid community string oid 
and its value in the response i.e. [1.3.6.1.6.3.6.1.2.3.0]. but i am not getting 
any of the above said items.

Please let me know the expected behavior.

Here is the sample code i am using:



Address targetAddress = GenericAddress.parse("udp:10.31.88.93/161");
TransportMapping transport = new DefaultUdpTransportMapping();
                        PDU pdu = new PDU();
Snmp snmp = new Snmp(transport);
CommunityTarget target = new CommunityTarget();
target.setVersion(SnmpConstants.version2c);
target.setAddress(targetAddress);
target.setCommunity(new OctetString("private12"));
transport.listen();

pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.2.1.0"))); 
pdu.setType(PDU.GET);

ResponseEvent response = snmp.get(pdu, target);
PDU pduResponse = response.getResponse();
System.out.println("pdu response:::"+pduResponse);
Vector vbs = pduResponse.getVariableBindings();
System.out.println("Variable Bindings:::"+vbs);

Thanks & Regards,
Gangadhar.Katakam


      


More information about the SNMP4J mailing list