[SNMP4J] IllegalStateException
Frank Fock
fock at agentpp.com
Tue Aug 17 23:15:35 CEST 2004
I thought a small timeout would increase the probability, but
it could also be that the response came in just at the moment
a retry was sent out.
Frank
Brian_Teravskis at cargill.com wrote:
>Hmmm, I thought 5000 for the timeout (5 seconds?) was plenty large,
>although I have been seeing late arriving SNMP responses at that as
>well. Some of our routers are at the far end of the world from here, and
>it can take a while for sure.
>
>I had it lock on me again today with no error. I upgraded to the latest
>version of SNMP4J, though the code in this area does not look much
>different. I will do more logging, and try your fix if I run into it
>again.
>
>Thanks,
>
>Brian
>
>
>-----Original Message-----
>From: fock at agentpp.com [mailto:fock at agentpp.com]
>Sent: Tuesday, August 17, 2004 3:22 PM
>To: Teravskis, Brian /mtks
>Cc: snmp4j at agentpp.org
>Subject: Re: [SNMP4J] IllegalStateException
>
>
>Hello Brian,
>
>You are probably using very small timeout values?
>Nevertheless, the SNMP4J code can be improved as
>follows to avoid this exception:
>
> if (pendingRequests.get(key) != null) {
> logger.debug("running pending request with handle" + key);
> PendingRequest nextRetry = new PendingRequest(this);
> long delay =
>
>timeoutModel.getRetryTimeout(target.getRetries()-retryCount,
> target.getRetries(),
> target.getTimeout());
> timer.schedule(nextRetry, delay);
> // register pending request not before it is scheduled
> pendingRequests.put(key, nextRetry);
> }
>
>Please let me know if this fixes the problem.
>
>Thanks in advance,
>Frank
>
>Brian_Teravskis at cargill.com wrote:
>
>
>
>>Hello,
>>
>>I'm using snmp4j for ARP cache gathering of network devices, and the
>>poller I wrote generated the following error message to the console:
>>
>>java.lang.IllegalStateException: Task already scheduled or cancelled
>> at java.util.Timer.sched(Unknown Source)
>> at java.util.Timer.schedule(Unknown Source)
>> at org.snmp4j.Snmp$PendingRequest.run(Snmp.java:670)
>> at java.util.TimerThread.mainLoop(Unknown Source)
>> at java.util.TimerThread.run(Unknown Source)
>>
>>The origin of the problem seems to be:
>>
>> public void run() {
>> if (retryCount > 0) {
>> retryCount--;
>> try {
>> send(pdu, target);
>> if (pendingRequests.get(key) != null) {
>> logger.debug("running pending request with handle" + key);
>> PendingRequest nextRetry = new PendingRequest(this);
>> pendingRequests.put(key, nextRetry);
>> long delay =
>>
>>timeoutModel.getRetryTimeout(target.getRetries()-retryCount,
>> target.getRetries(),
>> target.getTimeout());
>>--> timer.schedule(nextRetry, delay);
>> }
>> }
>>
>>It appears that this exception is not being caught and handled, and
>>therefore the error. My thread is catching IOException and then
>>Exception, and is not seeing this exception being thrown by the SNMP4J
>>routines. The thread I wrote appears to hang when this exception
>>
>>
>happens
>
>
>>waiting for a reponse. This is not a repeatable event. I've run this
>>poller several times without any issues. I'm doing the SNMP getnext
>>
>>
>with
>
>
>>a timeout of 5000 and a retry of 2.
>>
>>If any further information is required let me know.
>>_______________________________________________
>>SNMP4J mailing list
>>SNMP4J at agentpp.org
>>http://p15141779.pureserver.info/mailman/listinfo/snmp4j
>>
>>
>>
>>
>>
>
>
>
>
>
>
More information about the SNMP4J
mailing list