Hi Frank. Thanks for your quick answer. You are right, now it seems to work fine.
I have read the faq and the examples obviously (else I wouldn't be able to write the code) and in fact on my first try I was calling snmp.listen() on the sender, but did not call snmp.addNotificationListener() on the receiver. Instead I was calling snmp.addCommandResponder() and tried to send the acknowledgement manually which did not work for me. Anyway, thanks again. Regards, George On 20/12/2011 6:16 μμ, Frank Fock wrote: > Hi, > > You can find the answer in the FAQ. > On sender site you forgot to call snmp.listen(); > Without listening for incoming messages you cannot > receive them. > > Best regards, > Frank > > Am 20.12.2011 16:22, schrieb George Vasilakis: >> Hi all. >> >> I am trying to send v2 informs and successfully retrieve the >> acknowledgements. >> I am using the following code for the receiver and the sender respectively. >> >> Receiver: >> threadPool = ThreadPool.create("Trap", 2); >> dispatcher = new MultiThreadedMessageDispatcher(threadPool, >> new MessageDispatcherImpl()); >> listenAddress = >> GenericAddress.parse(System.getProperty("snmp4j.listenAddress", >> TRAP_LISTENER_UDP_ADDRESS)); >> snmp = new Snmp(dispatcher, new DefaultUdpTransportMapping()); >> snmp.addNotificationListener(listenAddress, this); >> snmp.getMessageDispatcher().addMessageProcessingModel(new >> MPv1()); >> snmp.getMessageDispatcher().addMessageProcessingModel(new >> MPv2c()); >> snmp.listen(); >> >> Sender: >> TransportMapping transport = new DefaultUdpTransportMapping(); >> Snmp snmp = new Snmp(transport); >> CommunityTarget target = new CommunityTarget(); >> target.setCommunity(this.communityString); >> target.setAddress(TRAP_LISTENER_UDP_ADDRESS); >> target.setRetries(1); >> target.setTimeout(1500); >> target.setMaxSizeRequestPDU(65535); >> target.setVersion(SnmpConstants.version2c); >> >> PDU pdu = new PDU(); >> pdu.setType(PDU.INFORM); >> List<VariableBinding> bindings = trap.getBindings(); >> sysUpTime = (System.currentTimeMillis() - this.startTime) / >> 10; >> pdu.add(new VariableBinding(SnmpConstants.sysUpTime, new >> TimeTicks(sysUpTime))); >> pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, >> trapOid)); >> >> for(VariableBinding binding : bindings) { >> pdu.add(binding); >> } >> ResponseEvent evt = snmp.inform(pdu, target); >> if(evt == null || evt.getResponse() == null) { >> System.err.println("Notification lost"); >> } >> else { >> System.out.println("Response: " + evt.getResponse()); >> } >> >> snmp.close(); >> >> The informs are successfully received on the receiver but no >> acknowledgment is sent back to the sender (or at least none is >> successfully retrieved by the sender). What am I doing wrong? >> >> Frankly, I am desperate and any help would be greatly appreciated. >> Thanks in advance. >> >> George >> _______________________________________________ >> SNMP4J mailing list >> SNMP4J@agentpp.org >> http://lists.agentpp.org/mailman/listinfo/snmp4j _______________________________________________ SNMP4J mailing list SNMP4J@agentpp.org http://lists.agentpp.org/mailman/listinfo/snmp4j