[SNMP4J] RE: No onResponse() when the target not set with correct SecurityName

Lin, Dongliang dongliang.lin at boeing.com
Thu May 10 18:19:29 CEST 2007


Hello,

Still waiting for any help about my questions:

Below is how I setup snmp and send the request to agent
===================

    	UserTarget target = (UserTarget)tgt; 	
    	String hostnamev3 = requestMsg.targ.agentAddress.host;
    	transport = new DefaultUdpTransportMapping();
    	Snmp snmp = new Snmp(transport);
        USM usm = new USM(SecurityProtocols.getInstance(),
                new OctetString(MPv3.createLocalEngineID()), 0);
        SecurityModels.getInstance().addSecurityModel(usm);
        
        OctetString authoritativeEngineID;
        OctetString contextEngineID;
        OctetString contextName = new OctetString();
        OctetString securityName = target.getSecurityName();
        OID authProtocol = authProtocolMap.get(hostnamev3);
        OID privProtocol = privProtocolMap.get(hostnamev3);
        OctetString authPassphrase = authPassphrseMap.get(hostnamev3); 
        OctetString privPassphrase = privPassphrseMap.get(hostnamev3); 

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

        
    	target.setAddress(targetAddress);
    	target.setRetries(requestMsg.targ.retries);
    	target.setTimeout(requestMsg.targ.timeout);
    	target.setVersion(target.getVersion());
    	target.setSecurityName(securityName);    <====== If I didn't
setup SecurityName here, No onResponse() being called ????
         log.debug( " sendSnmpRequestV3  securityName "  +
securityName.toHexString());
         target.setSecurityLevel(SecurityLevel.NOAUTH_NOPRIV);
    	snmpSessionMap.put( reqObject.toString() , snmp);
    	snmp.listen();
    	
        // creating PDU
    	ScopedPDU pdu = new ScopedPDU();
 
pdu.setType(SnmpUtil.convertPduType(requestMsg.requestPdu.type));
    	pdu.setContextName(new OctetString(""));
          .....
          snmp.getBulk( pdu, target, reqObject, this);

         .............
// onResponse() for result
 public  synchronized  void onResponse(ResponseEvent event) {}
================
However if target doesn't set properly, such as not setting
SecurityName, why the onResponse() didn't called at all ? I assume
timeout will make this being called.


Thanks in advance.

Don


> _____________________________________________ 
> From: 	Lin, Dongliang  
> Sent:	Wednesday, May 09, 2007 2:09 PM
> To:	'snmp4j at agentpp.org'
> Subject:	No onResponse() when the target not set with correct
> SecurityName
> 
> Hi Frank,
> 
> With the same code and right configuration (such as setting target,
> etc), there is correct response returned in onResponse().
> However, if I didn't set the target properly(such as wrong
> SecurityName), I assume there should be onResponse() also after
> timeout.
> (in my case, I just set the wrong SecurityName)
> But I didn't see the onResponse() being called.
> 
> Do I miss something ?
> 
> Thanks.
> 
> Don
> 
> 



More information about the SNMP4J mailing list