POE::Component::Client::HTTP not reconnecting, why?

albertocurro <[email protected]> Wed, 25 Jun 2014 19:12:38 +0200
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
------=_Part_45205_1414997889.1403716358574
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit

Hi everyone,

 I've found this problem with POE::Component::Client::HTTP, as when the endpoint (HTTP Server) shuts down, POE is not reconnecting after a while, even if the server comes up again. 

 This is part of the initialization code:

 POE::Session-&gt;create(
       inline_states =&gt; {
             _start =&gt; sub {
                   $_[KERNEL]-&gt;alias_set("store_remote_$self-&gt;{RIDX}");
                   $self-&gt;{SESSION} = $_[SESSION];
                   $_[HEAP]{self} = $self;                  
                   POE::Component::Client::HTTP-&gt;spawn(
                         Timeout =&gt; $config-&gt;get('remote_store')-&gt;[$idx]-&gt;{'request_timeout'},
                         Alias =&gt; $self-&gt;{ALIAS},
                         Proxy =&gt; $config-&gt;get('remote_store.proxy'),
                         Protocol =&gt; 'HTTP/1.1',
                         ConnectionManager =&gt; POE::Component::Client::Keepalive-&gt;new(
                               keep_alive =&gt; 1,
                               max_open =&gt; 100,
                               max_per_host =&gt; 100,
                               timeout =&gt; 10,
                                resolve_cb =&gt; sub { $self-&gt;_resolve_cb(@_); },
                         ),
                   );
            },
             on_handle =&gt; \&amp;_handle,
             on_response =&gt; \&amp;_response,
             on_read_dir_response =&gt; \&amp;_read_dir_response,
             on_mkdir_response =&gt; \&amp;_mkdir_response,
             on_retry =&gt; \&amp;_retry,
             _monitoring_tick =&gt; \&amp;_monitoring_tick,
       }
 );

  Looking for a possible similar issue in the mailing list database, I've found this message @ http://www.mail-archive.com/[email protected]/msg04735.html, where Gabor suggested to increase the number of max connections in the KeepAlive instatiation; changing it to 1000 instead of 100, the issue is gone.

I'd like to understand why this exactly happens. Maybe the client not freeing the connections when they can't be stablished? is this a known issue, or something designed this way? 

 I can see also that, from 1.357, the error shown in the logs is 408 Request timeout, while in previous versions was 111: connection refused. IMHO the previous one was more accurate than the one in 1.357, because the endpoint is down at this time.

 Regards
 Alberto







------=_Part_45205_1414997889.1403716358574
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>=
<meta content=3D"text/html;charset=3DUTF-8" http-equiv=3D"Content-Type"></h=
ead><body ><div style=3D'font-size:10pt;font-family:Verdana,Arial,Helvetica=
,sans-serif;'>Hi everyone,<br><br>  I've found this problem with POE::Compo=
nent::Client::HTTP, as when the endpoint (HTTP Server) shuts down, POE is n=
ot reconnecting after a while, even if the server comes up again. <br><br> =
This is part of the initialization code:<br><br>     <font face=3D"courier =
new,courier,monospace">POE::Session-&gt;create(<br>&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;        inline_states =3D&gt; {<br>            &nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _start =3D&gt; sub {<br>&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;                $_[KERNEL]-&gt;alias_set("store=
_remote_$self-&gt;{RIDX}");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           =
     $self-&gt;{SESSION} =3D $_[SESSION];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;                $_[HEAP]{self} =3D $self;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;                POE::Component::Client::HTTP-&gt;sp=
awn(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    &nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp; Timeout   =3D&gt; $config-&gt;get('remote_store')-&gt;[$id=
x]-&gt;{'request_timeout'},<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;                    Alias     =3D&gt; $self-&gt;{A=
LIAS},<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;                    Proxy     =3D&gt; $config-&gt;get('remote_store.pro=
xy'),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;                    Protocol  =3D&gt; 'HTTP/1.1',<br>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    Conne=
ctionManager =3D&gt; POE::Component::Client::Keepalive-&gt;new(<br>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;                        keep_alive    =3D&gt; 1,<br>&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        max_open      =3D&gt; =
100,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        max_per_host =
 =3D&gt; 100,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        time=
out       =3D&gt; 10,<br>                        &nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resolve_cb    =
=3D&gt; sub { $self-&gt;_resolve_cb(@_); },<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    ),<br>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;                );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            on_handle =3D&gt; \&amp;_h=
andle,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;            on_response =3D&gt; \&amp;_response,<br>&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            on_read=
_dir_response =3D&gt; \&amp;_read_dir_response,<br>&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            on_mkdir_respon=
se =3D&gt; \&amp;_mkdir_response,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            on_retry =3D&gt; \&amp;_retry=
,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;            _monitoring_tick =3D&gt; \&amp;_monitoring_tick,<br>&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>    );</font><br><br>&nbsp; Looking for a =
possible similar issue in the mailing list database, I've found this messag=
e @ http://www.mail-archive.com/[email protected]/msg04735.html, where Gabor sug=
gested to increase the number of max connections in the KeepAlive instatiat=
ion; changing it to 1000 instead of 100, the issue is gone.<br><br>I'd like=
 to understand why this exactly happens. Maybe the client not freeing the c=
onnections when they can't be stablished? is this a known issue, or somethi=
ng designed this way? <br><br>&nbsp;I can see also that, from 1.357, the er=
ror shown in the logs is 408 Request timeout, while in previous versions wa=
s 111: connection refused. IMHO the previous one was more accurate than the=
 one in 1.357, because the endpoint is down at this time.<br><br>&nbsp;Rega=
rds<br>&nbsp;Alberto<br><br><br><br><br><br></div></body></html>
------=_Part_45205_1414997889.1403716358574--