[SNMP4J] Reception of traps not working for me.

Frank Fock fock at agentpp.com
Sun Dec 27 00:19:59 CET 2009


The targetAddress variable is never used, so you do not assign
a port (and address) to the listener. Without a port and address,
SNMP4J choses all local host addresses and an arbitrary port
 > 1024. If you guess (and use) that port by the trap generator,
you will receive it.

Regards,
Frank

On 23.12.2009 22:09, darrick wrote:
> Looking at the example in the Snmp4j java docs I tried to implement a trap
> receiver but it is never getting executed. To ensure that the traps are
> actually being sent I am using iReasoning's MIB browser which has its own
> trap sender and trap receiver. The receiver is getting traps from both the
> trap receiver and a xerox printer that I have setup to send traps. I checked
> my windows box and made sure that the windows snmp services were all shut
> off. Any ideas? Below is my code:
>
> Address targetAddress =
> GenericAddress.parse("udp:127.0.0.1/162");
> TransportMapping transport = null;
>   try
> {
> transport = new DefaultUdpTransportMapping();
>   }
> catch ( IOException e1 )
> {
>   // TODO_djc Auto-generated catch block
> e1.printStackTrace();
> }
>
>
> Snmp snmp = new Snmp(transport);
>
> CommandResponder trapPrinter = new CommandResponder() {
>   public synchronized void processPdu(final CommandResponderEvent e) {
> wasHit = true;
>   PDU command = e.getPDU();
> if (command != null) {
>   System.out.println(command.toString());
> }
> }
>   };
>
> snmp.addCommandResponder(trapPrinter);
> try
>   {
> transport.listen();
> }
>   catch ( IOException e1 )
> {
> // TODO_djc Auto-generated catch block
>   e1.printStackTrace();
> }
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list