[SNMP4J] Snmp v2 invalid community string

Frank Fock fock at agentpp.com
Fri Dec 3 03:26:34 CET 2010


Hi,

The SNMP standard requires that a message
with a wrong community is not answered by
the agent at all.
Thus, you will always get a timeout.

Best regards,
Frank

On 02.12.2010 11:03, gangadhar katakam wrote:
> 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
>
>
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list