[SNMP4J] MPv1 used with unsupported security model
Martin Di Bella
mdibella at winit.com.ar
Tue Jan 11 22:09:00 CET 2005
Hi:
I'm trying to use snmp4j. When I run the program, get this message:
"MPv1 used with unsupported security model". Thanks.
Martin
** The stack trace print **
org.snmp4j.MessageException: Message processing model 0 returned error:
-1402
at
org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:354)
at org.snmp4j.Snmp.send(Snmp.java:356)
at org.snmp4j.Snmp.sendPDU(Snmp.java:292)
at SNMPTest.main(SNMPTest.java:72)
** The code **
public class SNMPTest {
public static void main(String[] args) {
// Create target
UserTarget target = new UserTarget();
UdpAddress address = new UdpAddress();
address.setPort(161);
try {
address.setInetAddress(InetAddress.getByName("192.168.0.40"));
} catch (UnknownHostException e) {
e.printStackTrace();
return;
}
target.setAddress(address);
// Create udp - Default pdu type is get
PDU request = new ScopedPDU();
request.add( new VariableBinding(SnmpConstants.sysDescr));
// Create snmp
Snmp snmp = null;
try {
snmp = new Snmp(new DefaultUdpTransportMapping());
} catch (IOException e1) {
e1.printStackTrace();
return;
}
// Message processing and security
MPv3 mp =(MPv3)
snmp.getMessageProcessingModel(MessageProcessingModel.MPv3);
USM usm = new USM(SecurityProtocols.getInstance(), new
OctetString(mp.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(usm);
// Send request
PDU response = null;
try {
response = snmp.sendPDU(request, target);
} catch (MessageException me) {
System.out.println(me.getStatusInformation());
me.printStackTrace();
return;
} catch (IOException e) {
e.printStackTrace();
return;
}
// Process response
if (response == null) {
System.out.println("time out");
} else {
VariableBinding vb = response.get(0);
System.out.println(vb);
}
}
}
More information about the SNMP4J
mailing list