[SNMP4J] How can I deal with cable disconnect when visit table?

Leon Li liysh at exavio.com.cn
Tue Aug 2 11:42:42 CEST 2005


Thank a lot.
Besides,I encounter 2 types of timeout.
one case  is plug out cable after message sent to agent.
I will know timeout occur by TableEvent (TableEvent .getStatus() = -1);

the other case is plug out cable before message sent to agent.
It'll stopped at "counter.wait()" below.
How should I deal with this case of timeout? 

SnmpRequest.java 
public void table() throws IOException {
    .......
    counter.wait();
    .......
}

Thanks,
Leo

----- Original Message ----- 
From: <fock at agentpp.com>
To: <snmp4j at agentpp.org>; <liysh at exavio.com.cn>
Sent: Saturday, July 30, 2005 5:37 AM
Subject: AW: [SNMP4J] How can I deal with cable disconnect when visit table?


> You can modify the timeout value by using the -t parameter.
> 
> Best regards,
> Frank
> 
>>
>>I use command  "snmp4j -v 2c -c public -Ot agentaddress 
>>1.3.6.1.4.1.19057.x.x.x(table entry OID)"
>>and when command is executing, I plug out cable.this command will wait and no 
>>response for a long time.
>>I can only use Ctrl-C to break.
>>
>>I add some print infomation("getTable passed") in table() of SnmpRequest.java 
>>
>>and then run it.I found stop at counter.wait() and there's no notify() 
>>invoked.
>>
>>Is there method to deal with this case?
>>
>>  public void table() throws IOException {
>>    Snmp snmp = createSnmpSession();
>>    this.target = createTarget();
>>    target.setVersion(version);
>>    target.setAddress(address);
>>    target.setRetries(retries);
>>    target.setTimeout(timeout);
>>    snmp.listen();
>>
>>    TableUtils tableUtils = new TableUtils(snmp, this);
>>    tableUtils.setMaxNumRowsPerPDU(maxRepetitions);
>>    Counter32 counter = new Counter32();
>>
>>    OID[] columns = new OID[vbs.size()];
>>    for (int i=0; i<columns.length; i++) {
>>      columns[i] = ((VariableBinding)vbs.get(i)).getOid();
>>    }
>>    long startTime = System.currentTimeMillis();
>>    synchronized (counter) {
>>
>>      TableListener listener;
>>      if (operation == TABLE) {
>>        listener = new TextTableListener();
>>      }
>>      else {
>>        listener = new CVSTableListener(System.currentTimeMillis());
>>      }
>>      if (useDenseTableOperation) {
>>        tableUtils.getDenseTable(target, columns, listener, counter,
>>                                 lowerBoundIndex, upperBoundIndex);
>>      }
>>      else {
>>        tableUtils.getTable(target, columns, listener, counter,
>>                            lowerBoundIndex, upperBoundIndex);
>>        System.out.println("getTable passed");//added by Leo
>>      }
>>      try {
>>        counter.wait();
>>      }
>>      catch (InterruptedException ex) {
>>       ex.printStackTrace();
>>      }
>>    }
>>    System.out.println("Table received in "+
>>                       (System.currentTimeMillis()-startTime)+" 
>>milliseconds.");
>>    snmp.close();
>>  }
>>_______________________________________________
>>SNMP4J mailing list
>>SNMP4J at agentpp.org
>><a 
>>href="http://lists.agentpp.org/mailman/listinfo/snmp4j">http://lists.agentpp.or
>>g/mailman/listinfo/snmp4j</a>
>


More information about the SNMP4J mailing list