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

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


Hi Frank, thanks for your answer.

By default I have a timeout of 1000 micro seconds.
I've tested increasing this time and the behavior is
the same. For example I've set the timeout to 5000
micro seconds. I think the timeout shouldn't has
influence because the tests are in the same machine
and there shouldn't be delay between the request and
the response.

I've just changed the asynchronous "send" method by
its equivalent synchronous one. And here the behavior
is correct: I always get the response.

Now, I'm doing this:
////
...
...
...
  PDU responsePDU = null;
  ResponseEvent responseEvent = null;
  responseEvent = snmp.send( requestPDU, target );
  if ( responseEvent != null )
    responsePDU = responseEvent.getResponse();
  snmp.close();
  // then, I process the response to show the
output...
...
...
...
///

And the output is like this:

///////////// *) Always successful for me !!!

[rodolfojcj at gandalf testPrograms]$ java -cp
.:lib/SNMP4J.jar:lib/log4j-1.2.7.jar 
ProgramWithSnmp4J
Se ha creado la vista
0 [main] DEBUG org.snmp4j.security.Salt  - Initialized
Salt to c545429a6909c503.
75 [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:67:fe:98:a0:02:01:00:02:01:00:30:0e:30:0c:06:08:2b:06:01:02:01:01:03:00:05:00
81 [main] DEBUG org.snmp4j.Snmp  - New pending request
with handle PduHandle[1744738464]
180 [Thread-1] INFO
org.snmp4j.transport.DefaultUdpTransportMapping  - UDP
receive buffer size for socket 150.187.64.101/0 is set
to: 32767
181 [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:67:fe:98:a0:02:01:00:02:01:00:30:11:30:0f:06:08:2b:06:01:02:01:01:03:00:43:03:03:d2:c9
278 [Thread-1] DEBUG org.snmp4j.Snmp  - Removing
pending request with handle PduHandle[1744738464]
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:41:45.69
/////////////

I will be more tests to see if I can catch what is
hapenning, and thanks again by the answers.

Bye,
Rodolfo José Castellanos Jaimes

 --- Frank Fock <fock at agentpp.com> escribió: 
> Hi Rodolfo,
> 
> Have you tried to increase the timeout value for
> your target yet?
> It seems that the agent's response is received too
> late (the timeout
> has already removed the corresponding request
> object).
> 
> Best regards,
> Frank
> 
> Rodolfo Josÿffffe9 Castellanos Jaimes wrote:
> 
> >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
> >_______________________________________________
> >SNMP4J mailing list
> >SNMP4J at agentpp.org
> >http://lists.agentpp.org/mailman/listinfo/snmp4j
> >
> >  
> >
> 
> 
>  

_________________________________________________________
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