[SNMP4J] Message processing model 3 returned error: 1401

chk-world at gmx.de chk-world at gmx.de
Fri Nov 19 11:50:34 CET 2004


Hello SNMP4J users,

I'm using the SNMP4J library to "getbulk" a list of oids via SNMPv3 from a
device. For this reason I wrote a class SNMPGetBulk which initialises
everything. Then (I thought) I only have to call snmp.sendPDU(request,
target) and would get a result as often as I call the method.

But its only working the first time. When I call snmp.sendPDU(request,
target) the second time (after 10 seconds or so) I get null as result and:

org.snmp4j.MessageException: Message processing model 3 returned error: 1401
at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:354)
at org.snmp4j.Snmp.send(Snmp.java:348)
at org.snmp4j.Snmp.sendPDU(Snmp.java:284)
...

I checked, but the request isn't even send out. What could be error 1401?

Any hint is appreciated.
Chris

Here is the class that I use to send:
public class SNMPGetBulk
{
  private String ip;
  private Snmp snmp;
  private PDU request = null;
  private UserTarget uTarget;

  public SNMPGetBulk(String ipAddress, Vector variableBindings)
  {
    this.ip = ipAddress;

    // simplified here
    OctetString securityName = new OctetString("snmpSecurityName");
    OctetString authPassphrase = new OctetString("snmpAuthPassphrase");
    OctetString privPassphrase = new OctetString("snmpPrivPassphrase");
    int timeout = Integer.parseInt("1000");
    int version = Integer.parseInt("3");

    OID authProtocol = AuthMD5.ID;
    OID privProtocol = PrivDES.ID;
    int retries = 1;
    int pduType = PDU.GETBULK;

    uTarget = new UserTarget();
    uTarget.setSecurityLevel(SecurityLevel.AUTH_PRIV);
    uTarget.setSecurityName(securityName);
    uTarget.setVersion(version);
    uTarget.setRetries(retries);
    uTarget.setTimeout(timeout);
    uTarget.setAddress(new UdpAddress(ipAddress + "/161"));

    request = new ScopedPDU();
    request.setType(pduType);
    int oidCount = variableBindings.size();

    // we have only scalar objects which can't be received with getnext
    request.setNonRepeaters(oidCount);
    request.setMaxRepetitions(oidCount);

    for (int i = 0; i < oidCount; i++)
    {
      request.add((VariableBinding) variableBindings.get(i));
    }

    DefaultUdpTransportMapping dutm = null;
    try
    {
      dutm = new DefaultUdpTransportMapping();
    } catch (IOException e)
    {
      e.printStackTrace();
    }

    dutm.setAsyncMsgProcessingSupported(false);
    TransportMapping transport = dutm;
    snmp = new Snmp(transport);
    USM usm = new USM(SecurityProtocols.getInstance(), new
OctetString(((MPv3) snmp
       
.getMessageProcessingModel(MessageProcessingModel.MPv3)).createLocalEngineID()),
0);
    SecurityModels.getInstance().addSecurityModel(usm);
    snmp.getUSM().addUser(securityName,
        new UsmUser(securityName, authProtocol, authPassphrase,
privProtocol, privPassphrase));
    try
    {
      snmp.listen();
    } catch (IOException e1)
    {
      e1.printStackTrace();
    }
  } // constructor

  public Vector get()
  {
    PDU response = null;
    try
    {
      response = snmp.sendPDU(request, uTarget);
    } catch (Exception e)
    {
      e.printStackTrace();
    }

    if (response == null)
    {
      // timeout case
      return null;
    } else if (response.getType() == PDU.REPORT)
    {
      // There is an error message from the device
      System.out.print("error from host: " + ip);
      return null;
    } else
    {
      return response.getVariableBindings();
    } // if response

  }

  protected void finalize() throws Throwable
  {
    snmp.close();
    super.finalize();
  }

} // class

-- 
Geschenkt: 3 Monate GMX ProMail + 3 Top-Spielfilme auf DVD
++ Jetzt kostenlos testen http://www.gmx.net/de/go/mail ++



More information about the SNMP4J mailing list