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

Frank Fock fock at agentpp.com
Tue Jul 12 00:14:02 CEST 2011


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

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




More information about the SNMP4J mailing list