[SNMP4J] Socket is closed exception
Frank Fock
fock at agentpp.com
Tue Jul 17 22:30:26 CEST 2007
Hi Mark,
In most cases using a single Snmp instance is appropriate.
It should be closed only if either the application is
exiting or if no SNMP communication is needed for a long
time (several hours or days). If you close a Snmp
instance, you need to make sure that it is no longer
used by any code/thread.
Best regards,
Frank
Mark Stang wrote:
> Hi,
> I have a question about how to set up multiple traps. In one case I am sending a "test" trap and in the other case I have a periodic trap being sent. After sending my test trap, I closed the instance of Snmp. That seems to have affected the periodic trap being sent. I went out of my way to try and isolate them by creating independent instances of Snmp, Target Community and the Listener. The only common instance is the PDU.
>
> 11:56:47,176 DEBUG [SnmpManagerImpl] Sending Test SNMP Trap
> 11:56:50,566 DEBUG [SnmpManagerImpl$2] Sending heartbeat
> 11:56:50,567 DEBUG [SnmpManagerImpl$2] IOExceptionorg.snmp4j.MessageException: Socket is closed
> 11:57:00,569 DEBUG [SnmpManagerImpl$2] Sending heartbeat
> 11:57:00,570 DEBUG [SnmpManagerImpl$2] IOExceptionorg.snmp4j.MessageException: Socket is closed
> 11:57:10,573 DEBUG [SnmpManagerImpl$2] Sending heartbeat
> 11:57:10,573 DEBUG [SnmpManagerImpl$2] IOExceptionorg.snmp4j.MessageException: Socket is closed
> 11:57:20,579 DEBUG [SnmpManagerImpl$2] Sending heartbeat
> 11:57:20,580 DEBUG [SnmpManagerImpl$2] IOExceptionorg.snmp4j.MessageException: Socket is closed
>
>
> Thoughts?
>
> Thanks!
>
> Mark
>
> Mark J. Stang
> Software Engineer
> office: +1 303.468.2900
> Ping Identity
>
>
>
> -----Original Message-----
> From: snmp4j-bounces at agentpp.org on behalf of Mark Stang
> Sent: Mon 7/16/2007 5:08 PM
> To: Gibbons, Sean; snmp4j at agentpp.org
> Subject: [SNMP4J] SNMP v1 trap
>
> Hi,
> I am trying to set up a periodic Trap, which I have running just fine. However, I need to set up a second Trap as a Test Trap until the user decides to persist the data. At that time, I need to cancel the old Trap and create a new one. All of which I can do except I am not sure which variables I can just make changes to/share and which ones I need to create "new" ones of.
>
> For instance, I can create an instance of the Snmp class, but it needs a transport. Does that mean each time I create a new instance of Snmp I have to create a new instance of the transport? And what about the CommunityTarget.
>
> transport = new DefaultUdpTransportMapping();
> snmp = new Snmp(transport);
> transport.listen();
> // setting up target
> target = new CommunityTarget();
>
> I need to be able to save off the old ones to kill them.
>
> private void cancelTimer()
> {
> if (timerTask != null)
> {
> log.debug("Canceling Heartbeat Timer");
> timerTask.cancel();
> }
> }
>
> When the timer task stops what does it have to do to kill the Trap?
>
> And finally, how much code do I need to just "send"? Should I re-create the instance of Snmp or just call the send method on it?
>
> thanks,
>
> Mark
> Mark J. Stang
> Software Engineer
> office: +1 303.468.2900
> Ping Identity
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
> _______________________________________________
> 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