[SNMP4J] Why 'stop' on SocketException in DefaultUdpTransportMapping.ListenThread?

Kelly Dyer Kelly.Dyer at quest.com
Tue Apr 30 23:05:59 CEST 2013


I am a little confused by this change.  

We have run into this issue, with a sporadic socket closed exception, the cause of which we have not been able to identify.  What we are seeing is that the new behavior results in a busy-loop, since we go right back to a receive that is guaranteed to fail.  

This strikes me as a case where we need to either remediate the socket directly, or cancel the listener.  What am I missing?

Regards,
Kelly.


On 12.07.2011 14:02, Fock, Frank wrote:
> Hi Gary,
>
> Your right, the current behavior is too strict.
> I have changed it as follows for the 2.0 release
> (will also change it for the 1.x branch too):
>
>          catch (SocketException soex) {
>            if (!stop) {
>              logger.error("Socket for transport mapping " + toString() +
>                           " error: " + soex.getMessage(), soex);
>            }
>            if (SNMP4JSettings.isFowardRuntimeExceptions()) {
>              stop = true;
>              throw new RuntimeException(soex);
>            }
>          }
>
> Best regards,
> Frank
>
> On 11.07.2011 16:29, Smith, Gary wrote:
> > Folks
> >
> > I'm using SNMP4j 1.11.3 and get occasional socket exceptions from certain devices, but not all.
> >
> > Current DefaultUdpTransportMapping.ListenThread.run() behaviour is to stop listening if any SocketException is caught (line 394).
> >
> > This kills the listener thread for every device, not  just the offending device.
> >
> > I have a badly behaved/config'ed device that is provoking an exception:
> >
> > Socket for transport mapping org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread at 1264c84 error: socket closed
> > java.net.SocketException: socket closed
> >         at java.net.PlainDatagramSocketImpl.receive0(Native Method)
> >         at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:136)
> >         at java.net.DatagramSocket.receive(DatagramSocket.java:712)
> >         at org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(Unknown Source)
> >         at java.lang.Thread.run(Thread.java:619)
> >
> >
> > This effectively kills the ListenThread for all my polled devices - by removing the "stop = true;" line above, my application becomes resilient (although obviously I have some > config problems).
> >
> >
> > Thanks
> Gary
> > _______________________________________________
> > SNMP4J mailing list
> > SNMP4J at agentpp.org
> > http://lists.agentpp.org/mailman/listinfo/snmp4j



More information about the SNMP4J mailing list