<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:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@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;}
/* 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.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:2100910143;
        mso-list-type:hybrid;
        mso-list-template-ids:-442980970 704925104 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;
        mso-fareast-font-family:Calibri;
        mso-bidi-font-family:"Times New Roman";}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></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 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>