Repost: [SNMP4J] Problem receiving traps

Frank Fock fock at agentpp.com
Mon Apr 18 20:10:15 CEST 2005


Hi Mauricio,

Please find my comments inline:

Mauricio Reyes wrote:

>
> I have tested the SNMP4J tool without any modification, configured to 
> listen to traps from the snmpd demon, printed to the console. And it 
> works fine. The traps are received as expected. But in my application 
> it stops receiving. Basically I build a class that launches two 
> threads one to send and another to listen form traps. What 

Why are your running a thread for receiving messages? The transport
mapping already runs such a thread, there is no need to start an extra one.

> the class does is do some calculations and draw some information in a 
> JFrame. I don't know if this is why it stops working. The run method 
> in the thread is like this:
>
> public void run()
>  {
>    try
>    {
>        if (operation == LISTEN)
>        {
>          listen();
>        }
>    }
>    catch (IOException ex)
>    {
>        System.err.println("Error escuchando solicitud Traps: " + 
> ex.getMessage());
>        ex.printStackTrace();
>    }
>  }
>
So, the thread dies right after it started the transport mapping's 
listen thread.
Since the latter one is a daemon, it stops when your thread above stops.

> I just call the listen method as in the SnmpRequest file. Would all 
> the code help?
>
No. See above. What you did different is to run the extra thread.

> I haven't been able to trace the error. What could change from using 
> this in a thread and using it as in SnmpRequest?
>
See above.

Best regards,
Frank





More information about the SNMP4J mailing list