[SNMP4J] SNMP client works remotely but fails locally

Mark Harpt mharpt3 at cox.net
Fri Jan 26 15:26:41 CET 2018


Thank you for the reply. Do I just make up an engine ID, since createLocalEngineID seems to return the same one on both the agent and the client?  If I just make one up, how do I do that (beginner alert)?



Here's the relevant part of my test code:

    TransportMapping transport = new DefaultUdpTransportMapping();
    Snmp snmp = new Snmp(transport);

    OctetString localEngineId = new OctetString(MPv3.createLocalEngineID());    <<<<<<<<<<<<<<<<
    USM usm = new USM(SecurityProtocols.getInstance(), localEngineId, 0);
    SecurityModels.getInstance().addSecurityModel(usm);

    OctetString securityName = new OctetString("myuser");
    OID authProtocol = AuthMD5.ID;
    OID privProtocol = PrivDES.ID;
    OctetString authPassphrase = new OctetString("myauth");
    OctetString privPassphrase = new OctetString("mypriv");

    snmp.getUSM().addUser(securityName, new UsmUser(securityName, authProtocol, authPassphrase, privProtocol, privPassphrase));

    UserTarget target = new UserTarget();
    target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
    target.setSecurityName(securityName);
    
    target.setAddress(GenericAddress.parse(String.format("udp:%s/%s", "127.0.0.1", "161")));
    target.setVersion(SnmpConstants.version3);
    target.setRetries(2);
    target.setTimeout(60000);

    transport.listen();
    
    PDU pdu = new ScopedPDU();
    pdu.add(new VariableBinding(new OID("1.3.6.1.4.5.2.1.3"), new Integer32(1)));
    pdu.setType(PDU.SET);
    ResponseEvent event = snmp.send(pdu, target);
    if (event != null) {
        pdu = event.getResponse();
        if (pdu.getErrorStatus() == PDU.noError) {
          System.out.println("SET Successful!");
        } else {
          System.out.println("SET Unsuccessful.");
        }
    }
   


> On Jan 26, 2018, at 2:14 AM, Frank Fock <fock at agentpp.com> wrote:
> 
> Hi,
> 
> This is most likely an issue about using the same engine ID if both run locally. You must use a unique ID to get it working.
> 
> Best regards,
> Frank
> 
> 
> 
>> On 26. Jan 2018, at 02:39, Mark Harpt <mharpt3 at cox.net> wrote:
>> 
>> I wrote an SNMP client that talks to an agent (gets and sets) just fine if the client is on a separate Windows PC from the agent.  If the client is on the same Windows PC as the agent, the agent receives the message from the client but does not act upon it.  Any ideas?
>> 
>> _______________________________________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> https://oosnmp.net/mailman/listinfo/snmp4j
> 


More information about the SNMP4J mailing list