[SNMP4J] Problem with ResponseListener timeout (SNMP4J 1.9.3d)

Marcin Kokoszka mkokoszka82 at gmail.com
Tue Apr 21 12:06:42 CEST 2009


I'm using SNMP4J v1.9.3d
I'm not sure but probably I have found some error.
I have a problem with ResponseListener and timeouts. I'm sending some
request (broadcast address) to search SNMP devices through the network. With
previous SNMP4J v1.8.1 everything was and there was ok -> timeout after few
seconds and the message "end scan" was displayed but with new version of the
SNMP4J it seems that something is wrong. I have waited for the message "end
scan" but without any results. Do You have any idea?

UdpAddress targetaddress = new UdpAddress("255.255.255.255"+"/161");
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString(communityStringGet));
target.setVersion(SnmpConstants.version1);
target.setAddress(targetaddress);
target.setRetries(1);
target.setTimeout(timeout);

final PDU pdu = createPDU(target, PDU.GET);

for(int i = 0; i < vbs.size(); i++)
{
       pdu.add((VariableBinding)vbs.get(i));
}
 // sending request
 ResponseListener listener = new ResponseListener()
 {
      public void onResponse(ResponseEvent event)
      {
            if(event.getResponse() != null)
            {
                 System.out.println(event.getPeerAddress().toString());
            }
            else
             {
                    System.out.println("end scan");
                    snmp.cancel(pdu, this);
            }
       }
 };

        try
        {
            snmp.send(pdu, target, null, listener);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

Best regards
Marcin Kokoszka



More information about the SNMP4J mailing list