<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Sorry I forgot to mention that this bug can cause java clients which retry connections in the background to run out of open files/handles and crash the JVM.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> rabbitmq-discuss-bounces@lists.rabbitmq.com [mailto:rabbitmq-discuss-bounces@lists.rabbitmq.com] <b>On Behalf Of </b>Iain Hull<br><b>Sent:</b> 28 November 2011 12:26<br><b>To:</b> rabbitmq-discuss@lists.rabbitmq.com<br><b>Subject:</b> [rabbitmq-discuss] Socket leak in java client library<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-IE>Hi,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IE><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-IE>I have discovered a socket leak in the java client library when you try to connect to a non-existent host. I discovered this in version 2.5.1 but it also affects all versions after this. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IE><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-IE>The problem occurs when com.rabbitmq.client.ConnectionFactory.newConnection() is called with a bad hostname. In this case com.rabbitmq.client.ConnectionFactory.createFrameHandler(Address) creates a socket that is never returned or closed because of an IOException.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IE><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-IE>I have attached a simple java file, SocketLeak.java, file that reproduces the problem, simply run it and monitor the number of open files (or handles on windows).<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IE><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-IE>I have applied a fix for this and tested it on version 2.5.1 and to the latest from the default branch in the hg repo. The patch is attached, SocketLeakFix.diff. All the client tests pass, however there are currently 3 functional tests failing for me on the default branch both with and without my changes.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IE><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-IE>There appears to be a similar leak in com.rabbitmq.client.ConnectionFactory.newConnection(</span>Address[]<span lang=EN-IE>) where connections are created and never returned or closed when an IOException occurs, however I have not been able to reproduce a leak in this code, but have attached a speculative fix anyway.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IE><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-IE>I understand that you do not have a public bug tracker that I can use to monitor this issue, but can you give me a bug number to track?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IE><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-IE>Regards,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IE>Iain.<o:p></o:p></span></p></div></body></html>