[SNMP4J] Inconsistency found in Asynchronus communication

reena grace reena_5grace at yahoo.co.in
Thu Oct 20 08:26:09 CEST 2005


Hi
I am trying to retrieve data from target using asynchronous communication.
But i am not consistently getting the data .I am able to collect the data in one
out of many instances(of data fetch operation).I  am not able to find out what i am missing .
Please help me in conveying the reason for this behaviour.
I have tried with increasing the time-out but in vain ,although i am able to sniff the
response packeet through ethreal.So it is clear that my code piece is the culprit.
I am using snmp4j1.6 .Please suggest the reason.
Following is my code :
-------------------------------------------------------------------------------------------
 Address targetAddress = GenericAddress.parse("udp:XXX.XX.XX.XX/161");
    TransportMapping transport=null;
    try {
      transport = new DefaultUdpTransportMapping();
     } 
    catch (IOException e2) 
    {}
    Snmp snmp = new Snmp(transport);
    CommunityTarget target = new CommunityTarget();
    target.setAddress(targetAddress);
    target.setRetries(0);
    target.setTimeout(5000);
    target.setCommunity(new OctetString("Public"));
    PDU pdu = new PDU();
   pdu.add(new VariableBinding(new OID(".1.3.6.1.2.1.1.5.0")));
    pdu.setType(PDU.GET);
    try {
     transport.listen();
    } 
    catch (IOException e1) { }
     ResponseListener listener=new ResponseListener(){
     public void onResponse(ResponseEvent event) {
          System.out.println(event.getPeerAddress()+":"+ event.getResponse());
        }
       };
       try {
        snmp.send(pdu,target,null,listener);
    } catch (IOException e) {}
 }
---------------------------------------------------------------------------
Thanks in advance.
Reena
 

		
---------------------------------
 Yahoo! India Matrimony: Find your partner now.


More information about the SNMP4J mailing list