[SNMP4J] Problem:Unable to receive a response

Frank Fock fock at agentpp.com
Tue Jun 21 23:27:13 CEST 2005


Hi Mark,

This is one of the FAQ - see:
http://www.snmp4j.org/html/faq.html

Best regards,
Frank

Mark Chan wrote:

>Hi, 
>
>Below is the test script that i used to try and run snmp. However it
>seems i am unable to get a response form the specified machine. Any
>help to my problem is greatly appreciated.
>
>
>public class testingSNMP{
>	
>	public static void main(String[] args) throws IOException,
>InterruptedException{
>		
>		
>		Address targetAddress = GenericAddress.parse("udp:192.168.0.126/161");
>	
>		CommunityTarget target = new CommunityTarget();
>		target.setCommunity(new OctetString("public"));
>		target.setAddress(targetAddress);
>		target.setVersion(SnmpConstants.version1);
>		target.setRetries(1);
>//		 set timeout to 500 milliseconds -> 2*500ms = 1s total timeout
>		target.setTimeout(20000);
>
>		target.setVersion(SnmpConstants.version1);
>		Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
>		PDU request = new PDU();
>		request.add(new VariableBinding(new OID(".1.3.6.1.2.1.1.3")));
>		request.setType(PDU.GETNEXT);
>		
>		ResponseListener listener = new ResponseListener() {
>				public void onResponse(ResponseEvent event) {
>						PDU response = event.getResponse();
>						PDU request = event.getRequest();
>							if (response == null) {
>								System.out.println("Request "+request+" timed out");
>							}else{
>								System.out.println("Received response "+response+" on request "+
>													request);
>							}
>				}
>		};
>	
>		
>		snmp.send(request, target);
>		Thread.sleep(500);
>	
>	}
>	
>}	
>	
>
>  
>





More information about the SNMP4J mailing list