[SNMP4J] TransportMapping/Snmp close() takes up to 1 sec to complete

Kevin Stretch kevin.stretch at sjrb.ca
Thu Jan 26 18:20:13 CET 2006


I'm at a loss here.  If I don't close the snmp object I create I end up
with a bunch of open ports each time I create a new object:

 

tcp        0      0 0.0.0.0:1235                0.0.0.0:*
LISTEN      29149/java

udp        0      0 0.0.0.0:34524               0.0.0.0:*
29149/java

udp        0      0 0.0.0.0:34525               0.0.0.0:*
29149/java

udp        0      0 0.0.0.0:34526               0.0.0.0:*
29149/java

udp        0      0 0.0.0.0:34527               0.0.0.0:*
29149/java

udp        0      0 0.0.0.0:34528               0.0.0.0:*
29149/java

 

However If I attempt to use "close()" on either the Snmp object or
TransportMapping object it takes up to 1 second to complete:

 

1138295085444

1138295086439

 

1138295094187

1138295095187

 

1138295104089

1138295105090

 

The program is wrapped with the "Java Service Wrapper" to make it a
daemon.

The program uses multiple class variables to enable its use with a SAX
parser (legacy code).

It's running on Redhat Enterprise 4

The request is a V1 request (but it must also handle v3 requests).

 

The problem is that it's taking to long to do 1000 SNMP requests right
now.  Has anyone seen this behavior before and might have an idea what's
taking so long?

Below are a few pieces of sample code.

 

Thanks in advance,

-Kevin

 

 

 

                        //TransportMapping transport = new
DefaultUdpTransportMapping();

                        transport = new DefaultUdpTransportMapping();

                        snmp = new Snmp(transport);

 

                        MPv3 mpv3 =
(MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3);

                        usm = new USM(SecurityProtocols.getInstance(),
new OctetString(mpv3.createLocalEngineID()), 0);

 

 
SecurityModels.getInstance().addSecurityModel(usm);

                        transport.listen();

 

 

        public void close () throws IOException {

//if (snmp != null) snmp.close();

                if (transport != null ) {

                        Calendar cal = Calendar.getInstance();

                        System.out.println (cal.getTimeInMillis());

                        transport.close();

//trust me that this call doesn't take 1 second, I checked.

                        cal = Calendar.getInstance();

                        System.out.println (cal.getTimeInMillis());

                }

                }

 

 




More information about the SNMP4J mailing list