[SNMP4J] Simple Get Request

Frank Fock fock at agentpp.com
Tue May 12 20:15:27 CEST 2009


Snmp.listen() is missing. See FAQ.

Mark Roe wrote:
> Have a very simple program:
> 
> public static void main(String[] args) {
>       CommunityTarget target = new CommunityTarget();
>       target.setCommunity(new OctetString("w0lv3r1n3s!"));
>       Address address = GenericAddress.parse("udp:10.99.3.1/161");
>       target.setAddress(address);
>       target.setVersion(SnmpConstants.version2c);
>       target.setRetries(2);
>       target.setTimeout(1000);
> 
>       PDU pdu = new PDU();
>       pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.1.1"))); // sysDescr
>       pdu.setType(PDU.GETNEXT);
> 
>       try {
>      Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
>      ResponseEvent response = snmp.send(pdu, target);
>      PDU responsePDU = response.getResponse();
>      Address peerAddress = response.getPeerAddress();
>      System.out.print("here" + peerAddress);
>      System.exit(1);
> 
>       } catch (java.io.IOException ex) {
>       }
> 
>    }
> 
> However, response is always null.  I have performed packet captures and do
> in fact see the response from the polled device:
> NetScreen-5GT-WLAN version 5.3.0r3.0
> 
> Any idea what I may be doing wrong?

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




More information about the SNMP4J mailing list