[SNMP4J] SNMP client works remotely but fails locally

Frank Fock fock at agentpp.com
Fri Jan 26 16:59:20 CET 2018


If you are using the latest SNMP4J then the MPv3.createLocalEngineID already uses a randomly generated part, because this was a common error. To create a stable unique ID you can use the other method which takes an OctetString argument. The correct engine ID format is described in the SNMPv3 RFCs or some Wiki page. 

If the random variant is not working for you, then the random system is probably not will setup/initialized. This might also be a problem of the underlying OS.


> On 26. Jan 2018, at 15:26, Mark Harpt <mharpt3 at cox.net> wrote:
> 
> 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 <mailto: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 <mailto: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 <mailto:SNMP4J at agentpp.org>
>>> https://oosnmp.net/mailman/listinfo/snmp4j <https://oosnmp.net/mailman/listinfo/snmp4j>
>> 



More information about the SNMP4J mailing list