[SNMP4J] MessageException "Socket is closed"

Garry Gerossie gerossie at gmail.com
Wed Sep 22 23:33:54 CEST 2010


Hello,

I have just started using SNMP4J and am experiencing a strange issue with
it. I have a class called SnmpSession that looks like this

public class SnmpSession
{
    private Snmp snmp = null;
    private DefaultUdpTransportMapping udpTransport = null;

    public SnmpSession()
    {
        try
        {
            udpTransport = new DefaultUdpTransportMapping();
            udpTransport.listen();
        }
        catch( IOException e )
        {
            e.printStackTrace();
        }

        snmp = new Snmp( udpTransport );
    }
}


Along with some send methods that send data using the snmp object. I am
trying to use the TableUtils class to read the table asynchronously. In my
TableListener class I am checking the TableEvent for Exception and I am
frequently getting a MessageException with the detailed message
"Socket is closed". I am not explicitly calling close on either the
TransportMapping or the Snmp objects. I also do not think the socket is
being closed due to garbage collection because this only happens when
request volume is high. At low request volumes everything works fine. When I
am trying to read lots of tables from lots of different devices I see this
problem every time. Also, in my TableListener class the error is seen in the
finished() method, not the next() method. I've tried to spread the load
across multiple Snmp objects and also increased the buffer size of the UDP
socket. Neither approach had much effect, the problem still occurs.

Any thoughts or advice on fixing or working around this problem would be
greatly appreciated.

Cheers,
-Garry Gerossie



More information about the SNMP4J mailing list