[SNMP4J] SnmpEngineListener fired multiple time for same address

Frank Fock fock at agentpp.com
Wed Sep 25 19:55:24 CEST 2013


Hi Christy,

This is indeed not optimal to fire the event, even if the engine ID did 
not change
for an address. By replacing the method addEngineID in MPv3.java as 
follows you
can improve the behavior:

   public boolean addEngineID(Address address, OctetString engineID) {
     if (!Arrays.equals(this.localEngineID, engineID.getValue())) {
       OctetString previousEngineID = engineIDs.put(address, engineID);
       if ((snmpEngineListeners != null) && ((previousEngineID == null) 
|| (!previousEngineID.equals(engineID)))) {
         fireEngineChanged(new SnmpEngineEvent(this,
SnmpEngineEvent.ADDED_ENGINE_ID,
                                               engineID, address));
       }
       return true;
     }
     return false;
   }

The next version of SNMP4J will include this patch.

Best regards,
Frank

Am 25.09.2013 17:38, schrieb Christy Jones (christyj):
> Hi,
>
> I'm using version 2.0.2 and in the process of implementing a
> SnmpEngineListener.
>
>  From what I observe the even when I'm polling for the same Address the
> MPv3.addEngineID fires the listeners for every message sent.
>
> The if condition in MPv3.addEngineID to check with localEngineID does not
> appear to work well. The Address is available in the engineIDs map but the
> localEngineID does not match with the input engineID. The localengineID
> appears to default one.
>   
> Is there a specific reason to check against the localEngineID before
> adding to the engineIDs map ? Could we not check if the Address is there
> in endingIDs map directly?
>
>      (!Arrays.equals(this.localEngineID, engineID.getValue()))
>
> Christy
>
>
>
>

-- 
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231




More information about the SNMP4J mailing list