[SNMP4J] receiving traps
SARRA SABRINA - technolabs
Sabrina.Sarra at technolabs.it
Tue Dec 18 09:23:35 CET 2007
Hi all,
I'm using snmp4j in my application receiving trap on a fixed port
(i.e.5110) but I noted the following problem:
If I run 2 instance of the application, I receve the traps only on the
last instance, the port bind is done to the second instance run.
Below there is my code of init session, is it correct?
Is it possible to receive traps on the same port on both applications?
Is it possible to bind the same port?
I hope somebody help me.
Thanks,
Best regards,
Sabrina
threadPool = ThreadPool.create("Trap", 2);
dispatcher = new MultiThreadedMessageDispatcher(threadPool, new
MessageDispatcherImpl());
// Get Host IP Address to listen traps
String ipaddr = getIPTrap();
String Listen_Port ="5110";
listenAddress = GenericAddress.parse("udp:"+ipaddr+"/"+Listen_Port);
TransportMapping transport;
if (listenAddress instanceof UdpAddress) {
transport = new
DefaultUdpTransportMapping((UdpAddress)listenAddress,true);
}
else {
transport = new
DefaultTcpTransportMapping((TcpAddress)listenAddress);
}
snmp = new Snmp(dispatcher, transport);
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1());
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c());
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3());
USM usm = new USM(SecurityProtocols.getInstance(), new
OctetString(MPv3.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(usm);
snmp.addTransportMapping(transport);
snmp.listen();
<mailto:sabrina.sarra at technolabs.it>
More information about the SNMP4J
mailing list