[SNMP4J] Exception: Timer Already Cancelled

Robert Stacy rstacy at zcorum.com
Mon Mar 24 17:42:54 CET 2008


Robert Stacy wrote:
> Hi Everyone,
>
> I am currently writing software that polls devices on a network using 
> SNMP.  I am sending the OID in batches of 5 at a time to the device.  
> I wait 1 second, and if I have not received all of the replies in that 
> time I resend the OID that I am missing.  Currently while running the 
> program  I get the following exception quite often:
>
> normal exception: Timer already cancelled.
> java.lang.IllegalStateException: Timer already cancelled.normal 
> exception: Timer already cancelled.
>        at java.util.Timer.sched(Unknown Source)
>        at java.util.Timer.schedule(Unknown Source)
>        at org.snmp4j.Snmp$PendingRequest.pduHandleAssigned(Unknown 
> Source)
>        at org.snmp4j.MessageDispatcherImpl.sendPdu(Unknown Source)
>        at org.snmp4j.Snmp.sendMessage(Unknown Source)
>
>        at org.snmp4j.Snmp.send(Unknown Source)
>        at org.snmp4j.Snmp.send(Unknown Source)
>
> Is this because I have already received the response for the request?  
> Why would I get this exception?
>
>
> Thanks,
> Rob
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
>
I seem to be getting this exception when performing a snmp.send 
asynchronously.  At no point in my application do I call a snmp.close so 
that can't be it.  Also, the snmp class is static and 
created/initialized in a static method.

    private static final Logger logger = 
Logger.getLogger(ZCorumSnmpPoller.class);
    protected static Snmp snmp;
    protected static ThreadPool snmpThreadPool;
    private int snmpTimeOut = 1000;
   
    static
    {
        try
        {
            //TODO: Make the number of snmp threads configurable
            snmpThreadPool = ThreadPool.create("devicePoller", 10);
            MessageDispatcher dispatcher = new MessageDispatcherImpl();
            dispatcher.addMessageProcessingModel(new MPv2c());
            MultiThreadedMessageDispatcher multithreadedDispatcher = new 
MultiThreadedMessageDispatcher(snmpThreadPool, dispatcher);
            TransportMapping transport = new DefaultUdpTransportMapping();
            snmp = new Snmp(multithreadedDispatcher, transport);           
            //snmp = new Snmp(transport);
            transport.listen();
           
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
           
        }
    }


I am at a loss as to why I would get this exception.

Thanks for all your help,
Rob




More information about the SNMP4J mailing list