Hi Frank, We do call snmp.listen() with every request we send. This ensures ListenThread is recreated, but I see that the when the socket closed exception happens and listener was reset to null, the socket instance remained as is and was not set to null. Hence I think ensureSocket() will never recreate and rebind the DatagramSocket since old socket instance remains in DefaultUdpTransportMapping ?
Thanks, Prema -----Original Message----- From: Frank Fock [mailto:[email protected]] Sent: Thursday, July 10, 2014 4:53 PM To: Prema Upot; [email protected] Subject: Re: [SNMP4J] Socket closed exception Hi Prema, Simply call "listen()" on the TransportMapping to start it again. Best regards, Frank Am 10.07.2014 22:00, schrieb Prema Upot: > Hi Frank, > > I was going to SNMP4J logs and I noticed that ListenThread of > DefaultUdpTransportMapping stopped because socket closed for some reason. > > 014-07-09 09:52:28,303 ERROR [ ransportMapping_172.21.0.169/0 ] Socket for > transport mapping > org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread@17add1b error: > socket closed > java.net.SocketException: socket closed > at java.net.PlainDatagramSocketImpl.receive0(Native Method) > at java.net.PlainDatagramSocketImpl.receive(Unknown Source) > at java.net.DatagramSocket.receive(Unknown Source) > at > org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:339) > at java.lang.Thread.run(Unknown Source) > 2014-07-09 09:52:28,303 DEBUG [ ransportMapping_172.21.0.169/0 ] Worker task > stopped:org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread > > From this point onwards, I see that every request has socket closed error. > > We have modelled our main SNMP interface based on the SNMPRequest.java class > included with SNMP4j and we are creating a new instance of this class every > time. But there is only one instance of SNMP class that is statically created > within this SnmpRequest. This was done based on your suggestion ( that was > way back in 2012 : ) to fix snmp timeout problem (snmp response received > from network but snmp4j stack reported timeout). Hence in the end we have > only one instance of DefaultUdpTransportMapping and with the ListenThread > closed, we will always be in error mode until we restart the server. > Is there anything we can do to recreate the ListenThread? I have no clue why > the socket closed in the first instance. We have been running this code for a > few years now and this problem has surfaced only quite recently. > > Thanks, > Prema > > -----Original Message----- > From: SNMP4J [mailto:[email protected]] On Behalf Of Frank Fock > Sent: Wednesday, July 09, 2014 2:22 PM > To: [email protected] > Subject: Re: [SNMP4J] Socket closed exception > > Hi Prema, > > Most likely, someone is calling Snmp.close() or the close() method of the > underlying transport mapping while other code is still using the same Snmp > session. > Another option would be the operating system or JRE closing the socket itself > for some reason (unlikely). > > Best regards, > Frank > > Am 09.07.2014 20:12, schrieb Prema Upot: >> Hi, >> >> We use SNMP4j 1.11 version. Recently we have been seeing a lot of socket >> closed exceptions while sending SNMP get/set messages. We have been using >> this version of SNMP4J for a long time in our application (and we have not >> modified the way we use the SNMP4J API at all) and we have never seen this >> before. This happens when we try to send a set of SNMP requests within a >> short period of time to different hosts (like periodic SNMP polling of a >> group of devices). Any ideas why this is happening ? Once this happens the >> only way to recover from this state is to restart my application. >> >> This is a sample exception that I see in my log file. >> >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> java.net.SocketException: Socket is closed >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at java.net.DatagramSocket.send(Unknown Source) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at >> org.snmp4j.transport.DefaultUdpTransportMapping.sendMessage(DefaultUdpTransportMapping.java:115) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at >> org.snmp4j.MessageDispatcherImpl.sendMessage(MessageDispatcherImpl.java:195) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at >> org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:462) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at org.snmp4j.Snmp.sendMessage(Snmp.java:1078) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at org.snmp4j.Snmp.send(Snmp.java:891) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at org.snmp4j.Snmp.send(Snmp.java:871) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at org.snmp4j.Snmp.send(Snmp.java:836) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at com.optelian.common.SnmpRequest.send(SnmpRequest.java:396) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at com.optelian.common.SnmpRequest.send(SnmpRequest.java:370) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at >> com.optelian.common.OMSSnmp4JDeviceInterface.readFields(OMSSnmp4JDeviceInterface.java:353) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at >> com.optelian.common.OMSDeviceManager.readFields(OMSDeviceManager.java:74) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at >> com.optelian.topology.server.util.ShelfInterface.readProperties(ShelfInterface.java:220) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at >> com.optelian.topology.server.util.ShelfInterface.readReleaseString(ShelfInterface.java:170) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at >> com.optelian.topology.server.discovery.ShelfPolling.pollOMSNode(ShelfPolling.java:181) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at >> com.optelian.topology.server.discovery.ShelfPolling.run(ShelfPolling.java:63) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown >> Source) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) >> [09 Jul 2014 13:44:20:653] [ polling-11 ] SYS_ERR: >> at java.lang.Thread.run(Unknown Source) >> >> Any help in debugging this problem is much appreciated. >> >> Thanks, >> Prema >> >> _______________________________________________ >> SNMP4J mailing list >> [email protected] >> https://oosnmp.net/mailman/listinfo/snmp4j > -- > --- > AGENT++ > Maximilian-Kolbe-Str. 10 > 73257 Koengen, Germany > https://agentpp.com > Phone: +49 7024 8688230 > Fax: +49 7024 8688231 > > _______________________________________________ > SNMP4J mailing list > [email protected] > https://oosnmp.net/mailman/listinfo/snmp4j -- --- AGENT++ Maximilian-Kolbe-Str. 10 73257 Koengen, Germany https://agentpp.com Phone: +49 7024 8688230 Fax: +49 7024 8688231 _______________________________________________ SNMP4J mailing list [email protected] https://oosnmp.net/mailman/listinfo/snmp4j
