[SNMP4J] Please help me

Frank Fock fock at agentpp.com
Wed Apr 7 23:07:44 CEST 2004


You can modify the Snmp.close() method as follows to fix the problem:

  public void close() throws IOException {
    for (Iterator it = 
messageDispatcher.getTransportMappings().iterator(); it.hasNext();) {
      ((TransportMapping)it.next()).close();
    }
    timer.cancel();  // <---- new to stop the timer thread
  }

This will fix the problem, but in case of pending request, those
listeners will not be called. A more clean approach will be
presented in the next release, which will be available on Tuesday
next week.

Best regards,
Frank

Vee wrote:

>           After I get beta2 version, everything works very fine, 
> except that after the result was retreived, the program didn't 
> terminate itself. I tried to put  .close method for both transport 
> object and snmp object but there was no difference, it still stucked 
> there as if it was still running some thread or listening for some 
> event until I had to press ctrl-break myself.
>  
>         // initialize  
>          .  
>          .
>          .
>
>         pdu.setType(PDU.GET);
>         pdu = protocol.sendPDU(pdu,myTarget);
>        
>         while (pdu==null)
>             System.out.println("Wait for response");
>         var=pdu.get(0);
>         Variable value = new Counter64();
>         value = var.getVariable();
>         System.out.println(value.toString());
>        
>         // here I try to free all resource by myself since the 
> previous run, the program didn't free resources itself and seemed it 
> was waiting for something happen. but though I put these in, there was 
> no difference. The same result was still happened (program didn't stop)
>
>         pdu.clear();
>         transport.close();
>         protocol.close();
>         transport=null;
>         protocol=null;
>       }catch(IOException ex){
>           ex.printStackTrace();
>           System.out.println(ex.getMessage());
>       }               
>
> The debug message is :
>  
> DEBUG [main] - Initialized Salt to 4ccc36339ff38f98.
> DEBUG [main] - Sending message to 10.147.0.12/161 with length 45: 
> 30:2b:02:01:00:04:06:70:75:62:6c:69:63:a0:1e:02:04:7b:59:94:76:02:01:00:02:01:00:30:10:30:0e:06:0a:2b:06:01:02:01:02:02:01:10:01:05:00
> DEBUG [Thread-1] - Received message from /10.147.0.12 with length 57: 
> 30:82:00:35:02:01:00:04:06:70:75:62:6c:69:63:a2:82:00:26:02:04:7b:59:94:76:02:01:00:02:01:00:30:82:00:16:30:82:00:12:06:0a:2b:06:01:02:01:02:02:01:10:01:41:04:01:07:d1:76
> DEBUG [main] - New pending request with 
> handleorg.snmp4j.mp.PduHandle at 7b599476 
> <mailto:handleorg.snmp4j.mp.PduHandle at 7b599476>
> DEBUG [Thread-1] - Removing pending request with 
> handleorg.snmp4j.mp.PduHandle at 7b599476 
> <mailto:handleorg.snmp4j.mp.PduHandle at 7b599476>
> 17289590
> __
>  
>  
> the "17289590" is a result from querying the IfInOctets. program did 
> stop here at the cursor ( __ )   and no prompt displayed (it should 
> return  C:> __   )
>
> best regards,
> Jacky
>
>
> *Surmsak Mahittivanitcha [V]
> Address : 71/398 Pitt st. Sydney, NSW  2000*
> *Mob. : +61(4)-2165-5794*
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway 
> <http://us.rd.yahoo.com/evt=23609/*http://promotions.yahoo.com/design_giveaway/static/index2.html> 
> - Enter today 







More information about the SNMP4J mailing list