[SNMP4J] MPv1 used with unsupported security model

Frank Fock fock at agentpp.com
Tue Jan 11 23:20:02 CET 2005


Hi Martin,

Please compare your code carefully with the examples in the JavaDoc
of the Snmp class. There are several required configurations missing in
your code. What type of SNMP request do you want to send? SNMPv1
or SNMPv3?

Best regards,
Frank

Martin Di Bella wrote:

>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);
>			}		
>	}
>}
>
>
>
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://p15141779.pureserver.info/mailman/listinfo/snmp4j
>
>  
>





More information about the SNMP4J mailing list