[SNMP4J] Not able to send SNMP Trap Using DefaultTcpTransportMapping

Frank Fock fock at agentpp.com
Wed Mar 30 18:59:49 CEST 2016


Hi,

What means "unable to send"? Do you get an error message?
What type of trap receiver are you using?
What versions on both sides?

Have you realized that you are closing the TCP connection right after 
you have successfully send
the message? Sending the message does not mean that the receiver has 
already processed it!
When you close the connection, the receiver will by interrupted and 
probably (most likely)
drop the unprocessed message before processing it.

Best regards,
Frank

Am 30.03.2016 um 16:25 schrieb vikas br:
> I have to some traps on TCP 162  of Trap Receiver. But I am not able to
> send snmp trap on that server using snmp4j jar.
>
> I can send traps using DefaultUdpTransportMapping but not with
> DefaultTcpTransportMapping.
>
>
> Our Trap Receiver is listen on both tcp:1622 and udp:1622 port.
>
> Please let me know how can I achieve that.
>
> Code is below
> -------------------
>
>
> TransportMapping transport = null;
> TransportIpAddress address=null;
> try {
> address=new TcpAddress("<ip-address>"+"/"+1622);
> transport=new DefaultTcpTransportMapping();
> // address=new UdpAddress("ip-address"+"/"+1622);
> // transport=new DefaultUdpTransportMapping();
> transport.listen();
> Snmp snmp = new Snmp(transport);
> CommunityTarget target = new CommunityTarget();
> target.setCommunity(new OctetString("secure"));
> target.setVersion(SnmpConstants.version2c);
> target.setAddress(address);
> target.setRetries(1);
> target.setTimeout(2000);
> VariableBinding[] appSpecVbs = getTestVarBinds();
> PDU pdu = new PDU();
> pdu.addAll(appSpecVbs);
> pdu.setType(PDU.TRAP);
> snmp.send(pdu, target);
> transport.close();
> snmp.close();
>
> } catch (IOException e) {
> e.printStackTrace();
> } catch (Exception e) {
> e.printStackTrace();
> }
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> https://oosnmp.net/mailman/listinfo/snmp4j




More information about the SNMP4J mailing list