I’m using the Amazon AWS SDK in a Java application (Tomcat running on Linux). In particular, I’m using MqttClientConnection to send messages to a queue.
Each time I call publish(), at least one UDP connection is created that never goes away. I can detect these by running lsof at the Linux prompt.
I have tried creating a single long running instance and I have also tried making temporary instances which I’m explicitly disconnecting and closing when I’m done with them. Both strategies create the UDP sockets.
I expect that MqttClientConnection might have legitimate reason to hold such sockets open briefly to ensure message delivery but these build up and never disappear even after days. I should also note that I am waiting for the publish result (the Future) to complete before doing anything else.
Eventually my Java process will run out of memory and crash. It takes a couple of weeks, but I’m not content to simply ignore the problem and keep restarting the server.
Finally, I have used Java profiling tools (jmap) to confirm that there is at most one instance of MqttClientConnection present. So it’s not me leaking instances.