[SNMP4J] I loose the response PDU with asynchronous send method

Rodolfo Josÿffffe9 Castellanos Jaimes rodolfojcj at yahoo.com
Fri Mar 11 09:17:11 CET 2005


Hi friends.

I have the following code to send a GET PDU to
localhost. I'm testing with asynchronous methods.

This is the code of the method that I use to send the
PDU (I'm guiding me by the snmp4j_tool console app.
source code and some others that I've written):

///////////

public void send()
{
  try
  {
    this.target = createTarget();
    target.setVersion( snmpVersion );
    target.setAddress( targetAddress );
    target.setRetries( maxRetries );
    target.setTimeout( timeout );
		
    Snmp snmp = createSnmpSession();
    snmp.listen();
		
    // create the request PDU
    PDU requestPDU = createPDU( target );

    if ( requestPDU.getType() == PDU.GETBULK )
    {		
    }
    for ( int i=0; i < variableBindingsVector.size();
i++)
    {
      // add the variables that will be requested
      requestPDU.add( variableBindingsVector.get( i )
);
    }
    // the listener that will "listen" the response
PDU
    ResponseListener responseListener =
createResponseListener();
    // send the PDU
    snmp.send(requestPDU, target , null,
responseListener);
  }
  catch( IOException ioe )
  {
  }
} // end method send

///////////

Then, I compile and run a test application that
request some variables within the MIB-II System group.

When I run it, sometimes I get the response PDU (which
I process to produce some output) but sometimes I get
no answer. 

Here I show you two samples of differents outputs. I
put the Logger Level to Level.ALL with the aim of see
what could be hapenning. These outputs are produced by
the same code, in the same machine, with the same
packages of SNMP4J and Log4J.

/////  1) Not successful for me
[rodolfojcj at gandalf testPrograms]$ java -cp
.:lib/SNMP4J.jar:lib/log4j-1.2.7.jar 
ProgramWithSnmp4J
Se ha creado la vista
Se ha agregado el PduListener
0 [main] DEBUG org.snmp4j.security.Salt  - Initialized
Salt to 1c9c18862b9d60ca.
85 [Thread-1] INFO
org.snmp4j.transport.DefaultUdpTransportMapping  - UDP
receive buffer size for socket 150.187.64.101/0 is set
to: 32767
163 [main] DEBUG
org.snmp4j.transport.DefaultUdpTransportMapping  -
Sending message to 150.187.64.101/161 with length 43:
30:29:02:01:00:04:06:70:75:62:6c:69:63:a0:1c:02:04:0c:1b:6c:9e:02:01:00:02:01:00:30:0e:30:0c:06:08:2b:06:01:02:01:01:03:00:05:00165
[Thread-1] DEBUG
org.snmp4j.transport.DefaultUdpTransportMapping  -
Received message from
gandalf.unet.edu.ve/150.187.64.101/161 with length 46:
30:2c:02:01:00:04:06:70:75:62:6c:69:63:a2:1f:02:04:0c:1b:6c:9e:02:01:00:02:01:00:30:11:30:0f:06:08:2b:06:01:02:01:01:03:00:43:03:02:51:81
170 [main] DEBUG org.snmp4j.Snmp  - New pending async
request with handle PduHandle[203123870]

////

////  2) Successful for me !!!
[rodolfojcj at gandalf testPrograms]$ java -cp
.:lib/SNMP4J.jar:lib/log4j-1.2.7.jar 
ProgramWithSnmp4J
Se ha creado la vista
Se ha agregado el PduListener
0 [main] DEBUG org.snmp4j.security.Salt  - Initialized
Salt to 57d7e9f873b504dd.
67 [Thread-1] INFO
org.snmp4j.transport.DefaultUdpTransportMapping  - UDP
receive buffer size for socket 150.187.64.101/0 is set
to: 32767
79 [main] DEBUG
org.snmp4j.transport.DefaultUdpTransportMapping  -
Sending message to 150.187.64.101/161 with length 43:
30:29:02:01:00:04:06:70:75:62:6c:69:63:a0:1c:02:04:60:ae:54:67:02:01:00:02:01:00:30:0e:30:0c:06:08:2b:06:01:02:01:01:03:00:05:00
180 [Thread-1] DEBUG
org.snmp4j.transport.DefaultUdpTransportMapping  -
Received message from
gandalf.unet.edu.ve/150.187.64.101/161 with length 45:
30:2b:02:01:00:04:06:70:75:62:6c:69:63:a2:1e:02:04:60:ae:54:67:02:01:00:02:01:00:30:10:30:0e:06:08:2b:06:01:02:01:01:03:00:43:02:11:d1
277 [main] DEBUG org.snmp4j.Snmp  - New pending async
request with handle PduHandle[1622037607]
279 [Thread-1] DEBUG org.snmp4j.Snmp  - Removing
pending request with handle PduHandle[1622037607]
309 [Thread-1] DEBUG org.snmp4j.Snmp  - Removing
pending request with handle PduHandle[1622037607]
Adding 1 (oid, value) pairs
Se ha recibido el evento pduArrived...
 
 
        Error Index = 0
        Error Status = 0
        Error Status Text = Success
        PDU Type Number = -94
        PDU Type String = RESPONSE
        OID = Value ...
                 There are 1 responsed variables
                1.3.6.1.2.1.1.3.0 = 0:00:45.61
////

Well, that's all.
I hope you can help me.

Thanks in advance by your time and your help.

Rodolfo José Castellanos Jaimes.

_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com



More information about the SNMP4J mailing list