[SNMP4J] Asynchronous Messages
Frank Fock
fock at agentpp.com
Fri Dec 3 03:19:26 CET 2010
Hi,
You followed and incorrect example.
Do not send a message with any
MessageDispatcher if you do not know
what you are doing!
And do not start with a
MultiThreadedMessageDispatcher. for
most usages it provides no advantages.
Just use the Snmp class to send your
PDUs.
Best regards,
Frank
On 02.12.2010 23:16, Marcel Bassuener wrote:
> Please,
> can anyone help me.
>
> I tried this method:
> http://lists.agentpp.org/pipermail/snmp4j/2006-January/001002.html
>
> Also I tried the Solution from the SNMP4J Wiki
>
> But I alway receive only one Response.
>
> This is the current Code:
>
> DefaultUdpTransportMapping defaultTransport = new
> DefaultUdpTransportMapping();
> defaultTransport.setReceiveBufferSize(65535);
> TransportMapping transport = defaultTransport;
>
>
> Snmp snmp = new Snmp(transport);
>
> OctetString localEngineID = new OctetString("Kaffee22");
>
> ((MPv3)snmp.getMessageProcessingModel(MPv3.ID)).
> setLocalEngineID(localEngineID.getValue());
>
> USM usm = new USM(SecurityProtocols.getInstance(),
> localEngineID,
> 0);
> SecurityModels.getInstance().addSecurityModel(usm);
>
> UserTarget target = new UserTarget();
> target.setSecurityLevel(SecurityLevel.NOAUTH_NOPRIV);
> target.setSecurityName(new OctetString("Detect"));
> target.setVersion(SnmpConstants.version3);
> target.setAddress(new UdpAddress("192.168.11.255/161"));
> target.setRetries(1);
> target.setTimeout(3000);
>
>
>
> MessageDispatcher md = snmp.getMessageDispatcher();
> MultiThreadedMessageDispatcher test = new
> MultiThreadedMessageDispatcher(ThreadPool.create("Requester", 4),md);
>
> test.removeCommandResponder(snmp);
> test.addCommandResponder(this);
> test.addCommandResponder(snmp);
>
> snmp.listen();
>
> ScopedPDU request = new ScopedPDU();
>
> request.setType(PDU.GET);//createPDU(target);
> if (request.getType() == PDU.GETBULK) {
> request.setMaxRepetitions(50);
> request.setNonRepeaters(1);
> }
> request.add(new VariableBinding(new OID("1.3.6.1.2.1.1.1.0")));
>
>
>
> PduHandle reqHandle = test.sendPdu(transport,
> target.getAddress(), target.getVersion(),
> SecurityModel.SECURITY_MODEL_USM,
> target.getSecurityName().getValue(),
> SecurityLevel.NOAUTH_NOPRIV, request, true);
>
> Thanks and Best regards
> Marshall
>
>
> Am 02.12.2010 14:57, schrieb Marcel Bassuener:
>> Hello,
>> I don't get asynchrnuos messeges to work.
>>
>> ResponseListener listener = new ResponseListener() {
>> public void onResponse(ResponseEvent event) {
>> System.out.println(event.getPeerAddress());
>> }
>> };
>>
>> snmp.send(request, target, usm, listener);
>>
>> The answer is everytime "null", but if i try the same with synch
>> messages it works.
>>
>> Or do you have an other suggestion how I can react on multible
>> responses, because the request goes to the broadcast address of the
>> Network (f.e. 192.168.11.255)
>> _______________________________________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
--
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list