[SNMP4J] Problems with DefaultTCPTransportMapping

Daphna Wasserman (dwasserm) dwasserm at cisco.com
Sun May 4 22:28:58 CEST 2008


Hi Frank,

Thanks for your prompt reply.

As for the dedicated thread issue, I'll apply your recommendations.
Thanks.

We're currently using a simple java-based SNMP client to test our code.
When we initialize the DefaultTCPTransportMapping before starting the
SNMP client, the transport mapping will report
"java.net.ConnectException: Connection refused" Exceptions, but once the
client is started, the mapping will not recover and will not send
messages.

Any suggestions?

Thanks 
Daphna



-----Original Message-----
From: Frank Fock [mailto:fock at agentpp.com] 
Sent: Sunday, May 04, 2008 9:41 PM
To: Daphna Wasserman (dwasserm)
Cc: snmp4j at agentpp.org; Ido Weiss (idweiss)
Subject: Re: [SNMP4J] Problems with DefaultTCPTransportMapping

Hi Daphna,

First of all, creating a dedicated thread for each
target is not a good idea. It takes up unnecessary
resources and slows down the application. More worse,
it can create other problems, for example, if
you do not share transport mappings.

To send out messages, you can use a single transport
mapping per protocol. If you create and close (hopefully)
transport mappings often, you can get many ports on
your machine in CLOSE_WAIT state and run out of ports.

Your particular problem could be caused by something
similar. If the client is shutdown ungracefully,
then the TCP connection hold by the notification
originator is half-closed and the server will probably
not recognize it until it send a packet that times
out after the TCP default timeout.

This issues is networking related and not related to
SNMP4J.

Best regards,
Frank

Daphna Wasserman (dwasserm) wrote:
> Hi,
> 
>  
> 
> Our application forwards SNMP V2 traps to different clients listening
on
> either TCP or UDP. For each combination of address+port we create a
> dedicated thread, and if the connection is of type TCP, we create an
> instance of DefaultTCPTransportMapping and use it to send messages to
> the specific client.
> 
>  
> 
> Currently we are using snmp4j.jar version 1.7.1 + java 1.5.0_08-b03
> 
>  
> 
> We have an issue in which after we restart the client (while the
server
> keeps trying to send traps to the client) , the new client instance
does
> not receive traps from the server any longer. We see the following
> message at the server log:
> 
> May 04 2008 16:10:02.469 IDT Snmp4JLogAdapter.debug DEBUG
>
{64.103.124.103/50004=SocketEntry[peerAddress=64.103.124.103/50004,socke
> t=Socket[unconnected],lastUse=Sun May 04 14:56:08 IDT 2008]}
> 
> May 04 2008 16:10:03.339 IDT Snmp4JLogAdapter.debug DEBUG Looking up
> connection for destination '64.103.124.103/50004' returned:
>
SocketEntry[peerAddress=64.103.124.103/50004,socket=Socket[unconnected],
> lastUse=Sun May 04 14:56:08 IDT 2008]
> 
>  
> 
> We've tried upgrading snmp4j to 1.8.2 and even to 1.9.1e with no
> improvement - after the client was restarted traps were still not
> received, and the following error appeared in the server log:
> 
>  
> 
> May 04 2008 11:46:35.015 IDT Throwable.printStackTrace ERROR
>>>>>>>>> SOut: java.lang.Exception: Stack trace
> 
> May 04 2008 11:46:35.015 IDT Throwable.printStackTrace ERROR
>>>>>>>>> SOut: at java.lang.Thread.dumpStack(Thread.java:1158)
> 
> May 04 2008 11:46:35.015 IDT Throwable.printStackTrace ERROR
>>>>>>>>> SOut: at
>
com.cisco.nm.cmp.net.protocols.snmp.Snmp4JLogAdapter.dumpFurtherInfo(Snm
> p4JLogAdapter.java:152)
> 
> May 04 2008 11:46:35.015 IDT Throwable.printStackTrace ERROR
>>>>>>>>> SOut:          at
>
com.cisco.nm.cmp.net.protocols.snmp.Snmp4JLogAdapter.error(Snmp4JLogAdap
> ter.java:57)
> 
> May 04 2008 11:46:35.015 IDT Throwable.printStackTrace ERROR
>>>>>>>>> SOut:          at
>
org.snmp4j.transport.DefaultTcpTransportMapping$ServerThread.processPend
> ing(Unknown Source)
> 
> May 04 2008 11:46:35.015 IDT Throwable.printStackTrace ERROR
>>>>>>>>> SOut:          at
>
org.snmp4j.transport.DefaultTcpTransportMapping$ServerThread.run(Unknown
> Source)
> 
> May 04 2008 11:46:35.017 IDT Throwable.printStackTrace ERROR
>>>>>>>>> SOut:          at java.lang.Thread.run(Thread.java:595)
> 
> May 04 2008 11:46:35.017 IDT Throwable.printStackTrace ERROR
>>>>>>>>> SOut:          at
> org.snmp4j.util.DefaultThreadFactory$WorkerThread.run(Unknown Source)
> 
> May 04 2008 11:46:35.017 IDT Snmp4JLogAdapter.debug DEBUG Firing
> transport state event:
>
org.snmp4j.transport.TransportStateEvent[source=org.snmp4j.transport.Def
>
aultTcpTransportMapping at 7546a399,peerAddress=64.103.124.103/50004,newSta
>
te=4,cancelled=false,causingException=java.nio.channels.ClosedChannelExc
> eption]
> 
> May 04 2008 11:46:35.017 IDT Snmp4JLogAdapter.error ERROR
> java.nio.channels.ClosedChannelException
> 
>  
> 
> We'll appreciate your help 
> 
> Thanks
> 
> Daphna
> 
>  
> 
>  
> 
>  
> 
>  
> 
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com



More information about the SNMP4J mailing list