JSLEE Discussions
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
SNMP org.snmp4j.MessageException: Invalid argument
Forum Index » Rhino SLEE Discussions
Author Message

Joined: 18/02/2014 09:28:36
Messages: 1

Has anybody encountered org.snmp4j.MessageException: Invalid argument
Logs while trying to push SNMP alarms:
2015-06-30 17:55:47.196 INFO [root] <GroupRMI-thread-1449> 2015-06-30 17:55:47.196,active,2015-06-30 17:48:39.389,101:171849571396615,RAEntityNotification[entity=diameter-ro],diameter.peer.connectiondown,diameter.peer.localhost,Warning,Connection to localhost:3869 is down,
2015-06-30 17:55:47.196 DEBUG [rhino.snmp.notification] <jmx-notification-thread-0> Handling notification: com.opencloud.rhino.logging.LogRolloverNotification[source=com.opencloud.rhino.logging.RhinoRollingFileAppender@653feb58][type=com.opencloud.rhino.logging.LogRolloverNotification][message=A log file has rolled over.]
2015-06-30 17:55:47.198 ERROR [rhino.snmp.notification] <jmx-notification-thread-0> Error sending SNMP PDU to community target:
org.snmp4j.MessageException: Invalid argument
at org.snmp4j.MessageDispatcherImpl.sendPdu(2.3-1.12-72630:485)
at org.snmp4j.Snmp.sendMessage(2.3-1.12-72630:1082)
at org.snmp4j.Snmp.send(2.3-1.12-72630:882)
at org.snmp4j.Snmp.send(2.3-1.12-72630:875)
at org.snmp4j.Snmp.send(2.3-1.12-72630:840)
at com.opencloud.ob.Rhino.mC.a(2.3-1.12-72630:245)
at com.opencloud.ob.Rhino.mC.a(2.3-1.12-72630:235)
at com.opencloud.ob.Rhino.mC.a(2.3-1.12-72630:92)
at com.opencloud.ob.Rhino.hj.handleNotification(2.3-1.12-72630:40)
at com.opencloud.rhino.management.NotificationHandler$b.run(2.3-1.12-72630:111)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

The destination IP is valid, a SNMP trapper is receiving messages sent manually via snmptrap -v 2c
 Filename rhino-snmp-invalid argument.log [Disk] Download
 Description full log description
 Filesize 794 Kbytes
 Downloaded:  1 time(s)

This message was edited 1 time. Last update was at 01/07/2015 03:07:45


Joined: 30/10/2018 05:44:18
Messages: 1

Found your question while searching for the same exception. I'm working in a different project, replying here in case it helps someone someday.

The "Invalid argument" message is generated when a datagram socket is used to send a trap to an IP that's different from the socket's bound address. (Or something like that.)
The solution in SNMP4J is to create a separate TransportMapping object for each target address. (You'll need to maintain the mapping of TransportMapping objects to your targets with your own code.) Then, pass your appropriate TransportMapping as an argument to Snmp.send(). Don't forget to first call listen() on the TransportMapping, if you are sending "confirmed" traps (aka. v2/v3 "INFORMS")... You only need to call listen() once per TransportMapping. To be thorough, you should probably call close() too, when your application is shutting down.

The underlying problem is that if you send a null TransportMapping to Snmp.send(), SNMP4J will happily find the *first* registered TransportMapping that supports the desired protocol (i.e. UDP vs TCP vs TLS), but it doesn't look to match the target address too. So you can't rely on SNMP4J to select the right TransportMapping if you have multiple trap destinations (targets).

Forum Index » Rhino SLEE Discussions
Go to:   
Powered by JForum 2.1.8 © JForum Team