[SNMP4J] Request for help: InterruptedException from DefaultUdpTransportMapping's ListenThread
dhinman at rcn.com
dhinman at rcn.com
Wed Jan 3 13:22:55 CET 2007
Hello,
I am using SNMP4J 1.5.1 on Windows XP.
I see periodic InterruptedException messages from the ListenerThread created by DefaultUdpTransportMapping. Here is the stack trace I get:
Exception in thread "Thread-25" java.lang.InterruptedException
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
at java.net.DatagramSocket.receive(DatagramSocket.java:712)
at org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:229)
Are these exceptions problematic (and if so, can I change my code to prevent the problem situation), or are they expected (and if so, can I somehow handle and ignore them)?
I have attached my code. Thanks very much for your help!
public FilerSample sampleFiler() throws IOException, SamplerDoneException {
transport = new DefaultUdpTransportMapping();
Address targetAddress = GenericAddress.parse("udp:" + filer + "/161");
long cpuUpTime = 0;
long cpuBusyTime = 0;
long cpuIdleTime = 0;
try {
snmp = new Snmp(transport);
USM usm =
new USM(SecurityProtocols.getInstance(),
new OctetString(MPv3.createLocalEngineID()),
0);
SecurityModels.getInstance().addSecurityModel(usm);
transport.listen();
// Here we set up the target
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("public"));
target.setAddress(targetAddress);
target.setRetries(5);
target.setTimeout(5000);
// create the PDU
PDU pdu = new PDU();
pdu.add(new VariableBinding(CPU_UP_TIME_OID));
pdu.add(new VariableBinding(CPU_BUSY_TIME_OID));
pdu.add(new VariableBinding(CPU_IDLE_TIME_OID));
pdu.setType(PDU.GET);
// send the PDU
ResponseEvent response = snmp.send(pdu, target);
// extract the response PDU (could be null if timed out)
PDU responsePDU = response.getResponse();
// … processing of the data from the PDU
}
finally {
// transport.close() and then snmp.close() in appropriate try/catch blocks
}
Dave Hinman
Dave.Hinman at mathworks.com
(508)647-4405
More information about the SNMP4J
mailing list