Find Your Device:
Or Continue to Thread: [Q] Snmp Get request error
22nd March 2014, 02:46 PM |#1  
OP Junior Member
Thanks Meter: 0
I'm build an android application using WebNMS library that apply snmp get operation on router but the result is null and this is the error message
"Error Sending PDU. IO error sending PDU. Send Error: null"
this is my code :
package com.example.snmptst;

import com.adventnet.snmp.beans.SnmpTarget;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Toast;

public class MainActivity extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
			SnmpTarget target;
			String targetHost;
			int targetPort;
			String community;			
			int timeout;
			int retries;
		    String returnString = null;	    	
		    targetHost = "";		
			targetPort = 161;	
			community = "public";	
			timeout = 5000;			
			retries = 2;			
			// Use an SNMP target bean to perform SNMP operations
			target = new SnmpTarget();
			target.setTargetHost(targetHost);	// set the agent hostname
			if(community != null) {	// set the community if specified
			target.setTargetPort(targetPort);	// set the port, default is 161
			// set the timeout/retries parameters, default are 5 and 0
			// Create oidList array from the obtained arrayList
			String []oidList = new String[1];
			// Set the OID List on the SnmpTarget instance
			String[] result = target.snmpGetList();	// do a get request
			// Return the result/error from the response.
			if(result != null) {
				String successString = "Response received.  Values:\n";		//No I18N
				for(int k=0; k<result.length; k++) {
					successString = successString + target.getObjectID(k) + " : " + result[k] + "\n";	//No I18N
				returnString = successString;
			} else {
				String errorString = "Request Failed or Timed-out. \n";		//No I18N
				errorString = errorString + target.getErrorString();
				returnString = errorString;
			Toast.makeText(getApplicationContext(), returnString, Toast.LENGTH_LONG).show();

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;
Any one can help me?