FIN_WAIT_2 happens when the local end of a socket is closed and the operating system is waiting for a signal that the remote end has closed their side. In your case, enough connections haven't that the operating system's socket table has filled, and new sockets can't be allocated.

I have a possible solution, but I don't have anything to test it against. If you could provide a test case that reliably triggers the problem, I can debug it quickly and turn around a better answer.

Meanwhile I have taken a guess at a solution, but you'll have to test it for me. If you can, please edit Client/Keepalive.pm (not Connection/Keepalive.pm). There should be a comment around line 582:

  # Build a connection object around the socket.

I need you to add these three lines before that comment (wherever it may be):

use Socket qw(SOL_SOCKET SO_LINGER); setsockopt($socket, SOL_SOCKET, SO_LINGER, pack("sll",1,0,0)) or die +( "setsockopt: $!" + );
When it comes time to close that socket, it should not linger in FIN_WAIT_2.

If that works for you, keep it free of charge. Also, let me know so I can include it in a future release.

Thank you.


In reply to Re: POE::Component::Client::HTTP, Keepalive, FIN_WAIT_2 by rcaputo
in thread POE::Component::Client::HTTP, Keepalive, FIN_WAIT_2 by nuclon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.