[SNMP4J] Was it a bug?
Vee
realvee2000 at yahoo.com
Thu May 27 12:56:51 CEST 2004
Hi all
I'm using SNMP v.1 for running some experiment. I got some bug from previous version of SNMP4J so I tried the latest one. My problem is that it couldn't get the SNMP values from device and throw the StackOverflowError exception. Has anyone got this similar problem? The code I wrote did work very well in the previous version of SNM4J. It returned the SNMP values successfully (however there was some internal problem that left the thread running forever. so I downloaded the new one but stucked) My code is quite simple. It just creates protocol, assigns target, sets pdu v.1 and sends it.
try{
transport = new DefaultUdpTransportMapping(); // create SNMP protocol
Snmp protocol = new Snmp(transport);
transport.listen(); // add listener
CommunityTarget myTarget = new CommunityTarget(); // set the target
Address deviceAdd;
deviceAdd = GenericAddress.parse("udp:"+ip+"/161");
myTarget.setAddress(deviceAdd);
myTarget.setCommunity(new OctetString(comm));
myTarget.setRetries(RETRY);
myTarget.setTimeout(TIMEOUT);
myTarget.setVersion(SnmpConstants.version1); // snmp v.1
pdu = new PDUv1(); // creates PDU v.1
VariableBinding var = new VariableBinding(new OID(INOCTETS));
pdu.add(var);
pdu.setType(PDU.GET);
pdu = protocol.sendPDU(pdu,myTarget);
var=pdu.get(0); // get the first value only
Variable value = new Counter64();
value = var.getVariable();
System.out.println(value.toString());
pdu.clear();
transport.close();
protocol.close();
transport=null;
protocol=null;
return Long.valueOf(value.toString());
}catch(IOException ex){
Any idea?
Thank you
Surmsak Mahittivanitcha [V]
Address : 71/398 Pitt st. Sydney, NSW 2000
Mob. : +61(4)-2165-5794
---------------------------------
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger
More information about the SNMP4J
mailing list