Hi Ali,

Please follow the JavaDoc documentation at:
http://www.snmp4j.org/doc/org/snmp4j/Snmp.html

You will not receive any response, because
you did not setup a listen port and transport
mapping. You did not call Snmp.listen() to
listen for responses. The default constructor
of Snmp does not create default message
processing models. That's why you get that
error.

Best regards,
Frank

Ali Daher wrote:
Hi all,

I want to send a request, but I am getting the following exception:

Exception in thread "main" org.snmp4j.MessageException: Unsupported message
processing model: 0

      at org.snmp4j.MessageDispatcherImpl.sendPdu(Unknown Source)

      at org.snmp4j.Snmp.sendMessage(Unknown Source)

      at org.snmp4j.Snmp.send(Unknown Source)

      at org.snmp4j.Snmp.send(Unknown Source)

      at GET.main(GET.java:58)

even though I am setting the right version.

I have going around the documentation to see what I am missing, but I am not
finding anything wrong.

I need some help here whether I am missing something or I am doing something
wrong

Looking forward for your help

Here is my code

public static void main(String[] args) throws IOException {
            Address targetAddress =
GenericAddress.parse("udp:192.168.178.14/161");

            CommunityTarget target = new CommunityTarget();

            target.setCommunity(new OctetString("public"));

            target.setAddress(targetAddress);

            target.setRetries(2);

            target.setTimeout(1500);

            System.out.println(SnmpConstants.version1);

            target.setVersion(SnmpConstants.version1);

            // creating PDU

            PDU pdu = new PDU();

            pdu.add(new VariableBinding(new OID(new int[]
{1,3,6,1,2,1,1,1})));

            pdu.add(new VariableBinding(new OID(new int[]
{1,3,6,1,2,1,1,2})));

      pdu.setType(PDU.GET);

      //    sending request

      ResponseListener listener = new ResponseListener() {

            public void onResponse(ResponseEvent event) {

                  //    Always cancel async request when response has been
received

                  //    otherwise a memory leak is created! Not canceling a
request

                  //    immediately can be useful when sending a request to
a broadcast

                  // address.

                  ((Snmp)event.getSource()).cancel(event.getRequest(),
this);

                  System.out.println("Received response PDU is:
"+event.getResponse());

            }

      };

      Snmp s= new Snmp();

      listener.onResponse( s.send(pdu, target));

}

Thanks in advance

Regards

Ali

_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j

--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com

_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j

Reply via email to