[SNMP4J] BindException: Address already in use, even with reuseAddress=true (with proposed fix)

Thomas L zlika_ese at hotmail.com
Tue May 26 22:13:14 CEST 2015


Hello,

I think I have found a bug in SNMP4J (2.3.3) where we can have a "BindException: Address already in use" exception when creating a DefaultUdpTransportMapping, whereas reuseAddress=true, if we have previously created and closed a similar DefaultUdpTransportMapping.
In DefaultUdpTransportMapping.close(), the listener thread (WorkerTask) is not "joined", so it can still use the UDP port for some time, and creating a new DefaultUdpTransportMapping on the same port, even if reuseAddress=true, is not possible.
My current dirty workaround is to access the "WorkerTask" field by reflection just before closing the Snmp object, and then calling "join()" on the object, so I am sure the thread is correctly terminated before any new attempt to create a new DefaultUdpTransportMapping.

Can this problem be solved in the next version of SNM4J?

Regards,
Thomas


More information about the SNMP4J mailing list