linhui (F | 4 May 05:12 2016

Bug report: org.snmp4j.MessageException: Socket is closed

In our code, we use Snmp Object to send a trap. The question is : while running for some time (may be a week) in
Windows platform, there will occur exception while sending trap.

The Exception stack is :
         org.snmp4j.MessageException: Socket is closed
         at org.snmp4j.MessageDispatcherImpl.sendPdu(
         at org.snmp4j.Snmp.sendMessage(
         at org.snmp4j.Snmp.send(
         at org.snmp4j.Snmp.send(

I have checked the source, The closed socket is DefaultUdpTransportMapping's DatagramSocket.

Another messages:

(1)     Before running the sending-trap thread, we use listen() function to listen the IP and port which is the
same as sending-trap IP and port.
For example, the IP is and port is 6666, we listen and use to send a trap.

(2)     SNMP4j's version is 1.11.2

At the beginning of the thread running, there are no exceptions occur. And I don't know why this exception occur.

Somebody can help me and explains this?

Best regards,
Lin Hui
(Continue reading)

Frank Fock | 3 May 23:51 2016

SNMP4J 2.5.0 and MIB Explorer 4.1.4 Released


SNMP4J 2.5.0 has been released and is now also available at Maven Central.
All other SNMP4J open source packages will also be updated and then 
on Maven Central too.


SNMP4J 2.5.0:
* Added [SFJ-120]: Maven Central deployment support (refactored pom.xml).
* Fixed [SFJ-118]: DefaultTcpTransportMapping: SocketEntry instances 
created for incoming TCP connections
   are not immediately removed when connection is closed remotely.
* Fixed [SFJ-119]: Snmp: NotificationListener cannot be registered with 
custom configured TransportMapping.
* Fixed [SFJ-121]: DefaultPDUFactory.createPDU does not set contextName 
and contextEngineID on ScopedPDU
* Fixed [SFJ-124]: ArgumentParser cannot parse formats with default 
values for parameters correctly.
* Added: Added MaxAccess, SubIndexInfo, and SubIndexInfoImpl to better 
support MIB specification
   based SNMP operations.
* Improved: Added custom OID configuration support for non-standard 
security protocols in
* Added PrivGeneric to reduce code size.
* Added SecurityPrivacy.isSupported() to be able to test security 
protocol support by JVM.
(Continue reading)

ru_44 | 27 Apr 19:10 2016

Subindex on table row

 For our custom MIB, we have added code to the MOValueValidationListener::validate() for a table column. 
 How do we figure out what the subindex is for the row's column that is being validated?
SNMP4J mailing list
SNMP4J <at>
ru_44 | 27 Apr 17:19 2016

No such instance on Sets

SNMP4J mailing list
SNMP4J <at>
Jonathan.Hopper | 27 Apr 13:21 2016

SNMP V3 and the user 'initial'

I have set up SNMP4j, and it is working well.  I have added functionality
to log when users connect for the first time, both successful and

What I am seeing is with some MIB browsers (iReasoning and ManageEngine)
using SNMPv3 there is a connection with a securityName 'initial'
happening, before connecting with my configured user.

Is this part of the protocol?  Is there a requirement that I have a user
named 'initial' configured?  If so what should that user be?

I have also seen connections with a blank security name "".

Jonathan Hopper |   APC by Schneider Electric   |  IT Business  |   Ireland
|   Senior Software Engineer

Email: Jonathan.Hopper <at>  |   Site:  |   Address: APC by Schneider Electric, City
East Business Park, Galway, Ireland

*** Please consider the environment before printing this e-mail

SNMP4J mailing list
SNMP4J <at>
Sudharani S | 25 Apr 08:16 2016

How to use SNMP in java for network discovery?

Hi ,

I am new SNMP protocol ,I have below requirement.Can anyone please help in this below requirement.

I need the guidance to start with this,I mean please let me know what all the things I need to include to do this.

And how to do snmp walk to pim neighbors table?,I have a snmp service enabled in my system apart from this what
all the jar files need to be include let me know please.

The requirement follows like this:
1)To implement multicast network discovery using snmp in java
2)Create CompletedRouterList (initially NULL) to store the routers for which discovery was complete and
a PendingRouterList containing the routers for which discover is pending.
3)At initialization time, statically populate the PendingRouterList with initial set of routers from
some config file.
4)For each router in the PendingRouterList, if multicast is enabled then query the pimInterfaceTable to
obtain the list of interfaces on which PIM is enabled. For example if R1 has PIM enabled and has interfaces
1/1 and 1/2/ on which PIM is enabled then we will have:-
            1/2         1/1
      --------- R1 ----------
5)For each router that has at least 1 interface that has PIM enabled on it, query it's PIM Neighbor table to
obtain the list of it's PIM neighbors. PIM neighbor table also gives the interface index with which the
router is connected with it's neighbor. This information can be used to build the link between the router
and neighbor(s).
For example if R1 has neighbors R2 connected to 1/1 and R3 connected to 1 / 2 then we can build the table as:-
                     1/2     1/1
         R3----------R1 ---------- R2

Anyone please help ,Thanks in advance

(Continue reading)

Fabio Ferreira | 15 Apr 15:51 2016

Personal training needed in SNMP4J (by skype/teamviewer)

Hi everybody

I am new in SNMP4J (and I'm not an expert in SNMP), and I want to work with
someone for this:

Personal training in how to use SNMP4J for implement basic agent for Scalar
values (no tables). The idea is to have a session (or sessions) by skype
and/or teamviewer to help me to understand fully intrumentation code and
agent creation from "baseagent" class.

If anyone is interested please write me with your price per hour. My email
is fabiorov <at>

Thanks in advance.
SNMP4J mailing list
SNMP4J <at>
Klaus Pittig | 15 Apr 12:37 2016

NPE possible during shutdown

Library-Version: snmp4j-agent-2.4.2.jar (together with snmp4j-2.4.3 and

I'm facing a minor(?) problem during Shutdown

On a (Windows 7) host with Java 8 (1.8.0_77) machine we use a java service
wrapper (yajsw-12) for an application that starts a JMXTestAgent clone. Works
fine so far, but on a Ctrl-C/SIGTERM the ShutdownHook starts and we sometimes
(not always) see the following NPE.


INFO|wrapper|16-04-14 18:14:57|stopping process with pid/timeout 7730 45000
INFO|wrapper|16-04-14 18:14:57|Shutting down Wrapper INFO|7730/0|16-04-14
18:14:57| wrapper manager received stop command FINEST|7730/0|16-04-14
18:14:57|java.lang.NullPointerException FINEST|7730/0|16-04-14 18:14:57| at
FINEST|7730/0|16-04-14 18:14:57| at
FINEST|7730/0|16-04-14 18:14:57| at$
FINEST|7730/0|16-04-14 18:14:57| at$
FINEST|7730/0|16-04-14 18:14:57| at
FINEST|7730/0|16-04-14 18:14:57| at
FINEST|7730/0|16-04-14 18:14:57| at
FINEST|7730/0|16-04-14 18:14:57| at
(Continue reading)

ru_44 | 13 Apr 19:56 2016

How to set value of MOScalar to no such instance

I am using the agent pro and created my own MIBs for snmp4j agent.
My question is how to I set the mib element to no such instance since it uses MOscalar for scalar attribute in
agent pro:
here is my code:




I can't change the null value to use the Null.nosuchInstance SMI constant.  
Is there a way to initialize the MIB value to no such instance.

Also I need to know how to set the value for any table row values also to return "no such instance" in MOScalar.

Rushik Patel
SNMP4J mailing list
SNMP4J <at>
Pim Moerenhout | 9 Apr 18:40 2016

Re: DateAndTime makeCalender improvement

Hi Frank,

This test case test the GregorianCalendar with all possible timezones which
fails with the 2.4.2 DateAndTime.makeCalendar

public void testDateAndTime() throws Exception {
  // 1st april 2016 UTC 00:00:00
  long testMillis = 1459468800000L;
  for (String timeZoneId : TimeZone.getAvailableIDs()) {
    GregorianCalendar gc = new
    OctetString dateAndTime = DateAndTime.makeDateAndTime(gc);
    int error = DateAndTime.validateDateAndTime(dateAndTime);
    if (error != 0) {
      System.out.println("SNMP error: " + error);

    // check the makeCalendar from the generated DateAndTime
    GregorianCalendar parsedGc = DateAndTime.makeCalendar(dateAndTime);
    long parsedGcMillis = parsedGc.getTimeInMillis();
    System.out.println(String.format("[%32s] The parsed millis %s: %5.1f
hours (" + gc
            .getTime() + " " + parsedGc.getTime() + ")", timeZoneId,
        (parsedGcMillis != testMillis ? "differs" : "equals "),
        (parsedGcMillis - testMillis) / 3600000.0));

Most timezones fail, except when using the default timezone (or equivalent).
(Continue reading)

Pim Moerenhout | 8 Apr 09:18 2016

DateAndTime makeCalender improvement

Hi Frank,

I was using the class in my Snmp4j
agent.I'm using the latest 2.4.2 release. I discovered that an DateTime
encoded OctetString was not parsed correctly, and having a different
Timezone then UTC generated other epoch values then expected.

When I changed the makeCalendar method as follows, it  works:

public static GregorianCalendar makeCalendar(OctetString dateAndTimeValue) {
  GregorianCalendar gc;
  if (dateAndTimeValue.length() == 11) {
    String timezone = String.format("GMT%c%02d:%02d",
        dateAndTimeValue.get(9), dateAndTimeValue.get(10));
    gc = new GregorianCalendar(TimeZone.getTimeZone(timezone));
    // localtime
    gc = new GregorianCalendar();
  int year = (dateAndTimeValue.get(0) & 0xFF ) * 256 +
      (dateAndTimeValue.get(1) & 0xFF );
  int month = (dateAndTimeValue.get(2) & 0xFF );
  int date = (dateAndTimeValue.get(3) & 0xFF );
  int hour = (dateAndTimeValue.get(4) & 0xFF );
  int minute = (dateAndTimeValue.get(5) & 0xFF );
  int second = (dateAndTimeValue.get(6) & 0xFF );
  int deci = (dateAndTimeValue.get(7) & 0xFF );
  gc.set(year, month-1, date, hour, minute, second);
(Continue reading)