perl.poe http://www.nntp.perl.org/group/perl.poe/ ... Copyright 1998-2015 perl.org Wed, 04 Mar 2015 17:44:43 +0000 ask@perl.org Re: POE::Component::Client::Keepalive crashes perl (5.16) on Windows by Rocco Caputo &gt; On Feb 15, 2015, at 06:59, Michael Lackhoff &lt;michael@lackhoff.de&gt; wrote: <br/>&gt; <br/>&gt; When it comes to the dependency mentioned <br/>&gt; in the Subject perl crashes several times during dmake test. It is not <br/>&gt; just a simple test failure but a Windows dialog box appears, saying that <br/>&gt; perl.exe has crashed. <br/> <br/>Hello, Michael. <br/> <br/>In these cases I usually use something like Devel::Trace to find out which line(s) of Perl were executing before the dialog pops up. Output will be super verbose, but it&#39;s the last ten lines (or so) that really matter. <br/> <br/>While it&#39;s possible to turn on crash dumps and examine them in a debugger, I&#39;ve found this to be generally unhelpful on Windows. The same goes for Windows system call traces. There&#39;s a tool for that, but Perl tends to crash in its own code. <br/> <br/>Please be sure you&#39;re using the latest available versions of POE, POE::Component::Resolver, and POE::Component::Client::Keepalive. The PPM build system is often stuck on some earlier version. <br/> <br/>It feels like the most problematic part of POE::Component::Client::Keepalive&#39;s stack would be POE::Component::Resolver. It&#39;s all &quot;pure Perl&quot;, but the resolver uses POE::Wheel::Run to move blocking DNS calls into subprocesses. <br/> <br/>POE::Wheel::Run uses Windows-specific modules to avoid problems with fork(). Many of these modules are bundled with Perl, but maybe PPM and/or CPAN contain newer versions. As a general recommendation, I suppose it wouldn&#39;t hurt to make sure these are up to date: Win32API::File, Win32::Console, Win32::Process, Win32::Job, and Win32. There may be unmet minimum version requirements for your particular setup. <br/> <br/>If you get Devel::Trace working, sending me the last output before the popup might help. <br/> <br/>-- <br/>Rocco Caputo &lt;rcaputo@pobox.com&gt; <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2015/02/msg5088.html Sun, 15 Feb 2015 18:36:06 +0000 POE::Component::Client::Keepalive crashes perl (5.16) on Windows by Michael Lackhoff Hi,<br/><br/>I am trying to install an application on a new PC that uses<br/>POE::Component::Client::HTTP to get web pages in parallel. But I am<br/>having problems installing it. When it comes to the dependency mentioned<br/>in the Subject perl crashes several times during dmake test. It is not<br/>just a simple test failure but a Windows dialog box appears, saying that<br/>perl.exe has crashed.<br/><br/>A previous installation from 2009 works without any problems but since<br/>it is still on XP I thought it is time for an update. As a possible<br/>workaround I even tried to install the old versions from 2009. With them<br/>I didn&#39;t get crashes but test failures and hangs during dmake test.<br/><br/>The current system I want to install it on is Windows 7 x64 with<br/>Strawberry Perl 5.16.3.1 32bit (but same result for 64 bit).<br/>It was much better with Perl 5.20.1 x64 (kept hanging in<br/>50_bisbee_timeout.t) but since there are no mod_perl binaries for 5.20<br/>yet, this is not an option for me. Because of other parts of my stack I<br/>am even bound to 32bit and for that 5.16 is the last one available (s.<br/>http://people.apache.org/~stevehay/)<br/><br/>Any ideas how to get it installed? Of course I am willing to do any<br/>debugging that might help fixing the problems.<br/><br/>Or are there any reliable alternatives I could use to load web pages in<br/>parallel within a cross platform application (Linux, Windows)?<br/><br/>-Michael<br/> http://www.nntp.perl.org/group/perl.poe/2015/02/msg5087.html Sun, 15 Feb 2015 11:59:28 +0000 POE::Kernel->stop() will trigger _stop in the next release by Rocco Caputo Hello, everyone. I hope you&#39;ve been well. <br/> <br/>It&#39;s come to my attention that POE::Kernel-&gt;stop() isn&#39;t triggering _stop handlers. This seems wrong, so I&#39;ve changed it. I hope it doesn&#39;t break anything, but I&#39;m mentioning it here in case people want to check in advance of a release. <br/> <br/>I&#39;ve already run it past irc.perl.org #poe, and nobody objected. <br/> <br/>-- <br/>Rocco Caputo &lt;rcaputo@pobox.com&gt; http://www.nntp.perl.org/group/perl.poe/2014/10/msg5086.html Thu, 30 Oct 2014 21:01:03 +0000 Project opportunity by Shaun Dawson I have a part-time cool Perl project opportunity for the right person. It<br/>will be working in Perl using POE on embedded systems, like Raspberry PI<br/>and BeagleBone. It&#39;s in aviation, of all industries, so it&#39;s got that cool<br/>factor as well. The initial phases of the project are pure Perl, but later<br/>phases will involve some web development, and maybe even some Android/IOS<br/>app development, so knowledge of those technologies would help as well.<br/><br/>Location doesn&#39;t matter, but the client is in Southern California, so if<br/>you are near there, there will be opportunity for flight tests and that<br/>sort of thing. Not required, but can be an added bonus :).<br/><br/>It&#39;s one of those things that starts off with a pretty tight budget with<br/>some opportunity for more work at the back end, but it&#39;s still a paid<br/>engagement. It&#39;s the kind of thing that might be ideal for a good<br/>developer trying to learn Perl.<br/><br/>If you are interested, or know of someone who might be, contact me<br/>directly, and let&#39;s have a chat and see if there is a good fit.<br/><br/>Best regards,<br/><br/>Shaun<br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/07/msg5085.html Wed, 16 Jul 2014 16:36:17 +0000 POE::Component::Client::HTTP not reconnecting, why? by albertocurro Hi everyone,<br/><br/> I&#39;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. <br/><br/> This is part of the initialization code:<br/><br/> POE::Session-&amp;gt;create(<br/> inline_states =&amp;gt; {<br/> _start =&amp;gt; sub {<br/> $_[KERNEL]-&amp;gt;alias_set(&quot;store_remote_$self-&amp;gt;{RIDX}&quot;);<br/> $self-&amp;gt;{SESSION} = $_[SESSION];<br/> $_[HEAP]{self} = $self; <br/> POE::Component::Client::HTTP-&amp;gt;spawn(<br/> Timeout =&amp;gt; $config-&amp;gt;get(&#39;remote_store&#39;)-&amp;gt;[$idx]-&amp;gt;{&#39;request_timeout&#39;},<br/> Alias =&amp;gt; $self-&amp;gt;{ALIAS},<br/> Proxy =&amp;gt; $config-&amp;gt;get(&#39;remote_store.proxy&#39;),<br/> Protocol =&amp;gt; &#39;HTTP/1.1&#39;,<br/> ConnectionManager =&amp;gt; POE::Component::Client::Keepalive-&amp;gt;new(<br/> keep_alive =&amp;gt; 1,<br/> max_open =&amp;gt; 100,<br/> max_per_host =&amp;gt; 100,<br/> timeout =&amp;gt; 10,<br/> resolve_cb =&amp;gt; sub { $self-&amp;gt;_resolve_cb(@_); },<br/> ),<br/> );<br/> },<br/> on_handle =&amp;gt; \&amp;amp;_handle,<br/> on_response =&amp;gt; \&amp;amp;_response,<br/> on_read_dir_response =&amp;gt; \&amp;amp;_read_dir_response,<br/> on_mkdir_response =&amp;gt; \&amp;amp;_mkdir_response,<br/> on_retry =&amp;gt; \&amp;amp;_retry,<br/> _monitoring_tick =&amp;gt; \&amp;amp;_monitoring_tick,<br/> }<br/> );<br/><br/> Looking for a possible similar issue in the mailing list database, I&#39;ve found this message @ http://www.mail-archive.com/poe@perl.org/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.<br/><br/>I&#39;d like to understand why this exactly happens. Maybe the client not freeing the connections when they can&#39;t be stablished? is this a known issue, or something designed this way? <br/><br/> 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.<br/><br/> Regards<br/> Alberto<br/><br/><br/><br/><br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/06/msg5084.html Wed, 25 Jun 2014 17:12:48 +0000 A scheduler with Reflex::Wakeup by Giacomo Montagner http://www.nntp.perl.org/group/perl.poe/2014/04/msg5083.html Wed, 09 Apr 2014 14:48:25 +0000 Re: Asunto: Re: Slow fork bomb message in latest version of POE by Rocco Caputo Hi again. <br/> <br/>What I mean is that I don&#39;t think you know what sig_child() does exactly, or how to use it. I base this impression on two things: First, you&#39;re calling sig_child() from a place where it will never work and at a time that is obviously too late to do anything. Second, it needs at least two parameters to work, but you&#39;re passing it nothing. <br/> <br/>I recommend not using SIGDIE for common exception handling. Its scope is too broad, and your code will get ugly. It&#39;s probably cleaner to use eval{} or Try::Tiny to convert your unexpected exceptions into expected ones. If you catch them explicitly, then POE won&#39;t need to raise them, and there should be less strange behavior. <br/> <br/>The problem seems to be migrating. I recommend caution against further clouding the original issue until it&#39;s resolved. <br/> <br/>If you resolve your exceptions issue, and if you resolve your sig_child() usage issue, then your program should not be interrupted at inopportune times, and it should reap the nginx process before it exits. This should resolve all outstanding issues, as I currently understand them. <br/> <br/>-- <br/>Rocco Caputo &lt;rcaputo@pobox.com&gt; <br/> <br/>On Mar 24, 2014, at 12:15, albertocurro &lt;albertocurro@zoho.com&gt; wrote: <br/> <br/>&gt; <br/>&gt; Hi, <br/>&gt; <br/>&gt; Sorry, but I don&#39;t catch what you exactly mean with &quot;not using sig_child() as intended&quot;. Do you mean calling it from the main session so each child process will be closed properly? <br/>&gt; <br/>&gt; The issue I have is how to handle unexpected exceptions. Seems they are thrown and raised without control, killing POE&#39;s kernel before in the way. I could be thinking in the timing in the wrong way, though... <br/>&gt; <br/>&gt; Alberto <br/>&gt; <br/>&gt; ---- Activado lun, 24 mar 2014 16:59:49 +0100 Rocco Caputo&lt;rcaputo@pobox.com&gt; escribi&oacute; ---- <br/>&gt; <br/>&gt;&gt; You are not using sig_child() as intended. When used as intended, sig_child() will prevent shutdown until the child process has exited and has been reaped. The timing issues you&#39;re worried about should not exist. <br/>&gt;&gt; <br/>&gt;&gt; -- <br/>&gt;&gt; Rocco Caputo &lt;rcaputo@pobox.com&gt; <br/>&gt;&gt; <br/>&gt;&gt; On Mar 24, 2014, at 11:44, albertocurro &lt;albertocurro@zoho.com&gt; wrote: <br/>&gt;&gt; <br/>&gt;&gt;&gt; Hi Rocco, <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; many thanks for your quick answer! Unfortunately, the provided solution only works partially. I still have some cases where the &quot;fork bomb&quot; message is here with us :( <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; One of the cases is this one: under some configuration, an instance of nginx is started, so our product writes the configuration file and starts the Nginx instance pointing to that configuration file. BUT, if the configuration file could not be written (directory does not exist, etc), then the error raises, and I&#39;ve not found any way to handle it: <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; DEBUG - Created nginx temporary directory /opt/tmp/pull/instance1 <br/>&gt;&gt;&gt; DEBUG - Created nginx configuration directory /opt/etc/pull/instance1 <br/>&gt;&gt;&gt; DEBUG - Created nginx log directory /opt/log/pull/instance1 <br/>&gt;&gt;&gt; DEBUG - creating nginx configfile for instance 1 in /opt/etc/pull/instance1 <br/>&gt;&gt;&gt; === 13991 === !!! Kernel has 1 child process(es). <br/>&gt;&gt;&gt; === 13991 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt; === 13991 === !!! Be sure to use sig_child() to reap child processes. <br/>&gt;&gt;&gt; === 13991 === !!! In extreme cases, failure to reap child processes has <br/>&gt;&gt;&gt; === 13991 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>&gt;&gt;&gt; Could not open file: No such file or directory <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; I&#39;ve added a DIE handler in the main session to try to handle this: <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; $sig_session = POE::Session-&gt;create( <br/>&gt;&gt;&gt; inline_states =&gt; { <br/>&gt;&gt;&gt; _start =&gt; sub { <br/>&gt;&gt;&gt; $_[HEAP]{RELOADED} = 0; <br/>&gt;&gt;&gt; $_[KERNEL]-&gt;sig(TERM =&gt; &#39;_sigterm&#39;); <br/>&gt;&gt;&gt; $_[KERNEL]-&gt;sig(INT =&gt; &#39;_sigterm&#39;); <br/>&gt;&gt;&gt; $_[KERNEL]-&gt;sig(DIE =&gt; &#39;_sigterm&#39;); <br/>&gt;&gt;&gt; $_[KERNEL]-&gt;sig(nginx_reload =&gt; &#39;_sig_nginx_reload&#39;); <br/>&gt;&gt;&gt; $_[KERNEL]-&gt;alias_set(&#39;sighandler&#39;); <br/>&gt;&gt;&gt; }, <br/>&gt;&gt;&gt; _sigdie =&gt; sub { <br/>&gt;&gt;&gt; print &quot;Handling exception, calling stop&quot;; <br/>&gt;&gt;&gt; POE::Kernel-&gt;call($sig_session, &#39;_stop&#39;); <br/>&gt;&gt;&gt; }, <br/>&gt;&gt;&gt; _stop =&gt; sub { <br/>&gt;&gt;&gt; # Reap any existing pid (# 1825119) <br/>&gt;&gt;&gt; print &quot;Handling stop&quot;; <br/>&gt;&gt;&gt; POE::Kernel-&gt;sig_child(); <br/>&gt;&gt;&gt; use POSIX &quot;:sys_wait_h&quot;; <br/>&gt;&gt;&gt; 1 while waitpid(WNOHANG, -1) &gt; 0; <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; # Clear signal handlers... <br/>&gt;&gt;&gt; $_[KERNEL]-&gt;sig(&#39;TERM&#39;); <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; But, as said above, it&#39;s not working. Checking POE&#39;s code, I can see the message lines are generated in Resources/Signals.pm, under _data_sig_finalize() method (where POE is already doing the same you recommended me, waiting for the pid). <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; But _data_sig_finalize() method is called in Kernel.pm just after unregistered all the signals (Kernel.pm =&gt; _finalize_kernel): <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; my $self = shift; <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; # Disable signal watching since there&#39;s now no place for them to go. <br/>&gt;&gt;&gt; foreach ($self-&gt;_data_sig_get_safe_signals()) { <br/>&gt;&gt;&gt; $self-&gt;loop_ignore_signal($_); <br/>&gt;&gt;&gt; } <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; # Remove the kernel session&#39;s signal watcher. <br/>&gt;&gt;&gt; $self-&gt;_data_sig_remove($self-&gt;ID, &quot;IDLE&quot;); <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; # The main loop is done, no matter which event library ran it. <br/>&gt;&gt;&gt; # sig before loop so that it clears the signal_pipe file handler <br/>&gt;&gt;&gt; $self-&gt;_data_sig_finalize(); <br/>&gt;&gt;&gt; $self-&gt;loop_finalize(); <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; Once here, none of my signal handlers in the main session instance would work, as the signals have been unregistered. On an exception (die) while POE::Kernel-&gt;run(), how could I handle it then?? <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; Thanks a lot <br/>&gt;&gt;&gt; Alberto <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; ---- Activado lun, 24 mar 2014 13:45:45 +0100 Rocco Caputo escribi&oacute; ---- <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt; Hi, Alberto. <br/>&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt; At program end time, POE runs a quick waitpid() check for child processes that may have leaked. This check was added after a bug report where POE locked up a server after several days of running. It turned out to be the reporter&#39;s application, but it was hard to debug. <br/>&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt; Your program seems to have created two processes that it didn&#39;t reap: PIDs 5373 and 5374. The ideal solution is to reap those processes before exiting. Your program can do this using POE::Kernel&#39;s sig_child() method. <br/>&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt; In some cases, a third-party library will create processes and not properly clean them up. It can be impossible to solve this case without modifying other people&#39;s code. <br/>&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt; If you just want to ignore the problem, this might do the trick. Put these lines in your last _stop handler. They should reap the processes you&#39;ve leaked before POE&#39;s check: <br/>&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt; use POSIX &quot;:sys_wait_h&quot;; <br/>&gt;&gt;&gt;&gt; 1 while waitpid(WNOHANG, -1) &gt; 0; <br/>&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt; It&#39;s a bit of a pain, but I think it&#39;s better to explicitly ignore the problem than for it to go unnoticed by default. <br/>&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt; Please let me know whether that resolves your problem. It may not. For example, the processes may still be open until an object is destroyed at global destruction time. <br/>&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt; -- <br/>&gt;&gt;&gt;&gt; Rocco Caputo <br/>&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt; On Mar 24, 2014, at 05:46, albertocurro wrote: <br/>&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt;&gt; Guys, <br/>&gt;&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt;&gt; We have a product developed using POE as a base framework, with some other tool libraries as log4perl; basically is a forward proxy, composed of several modules, each one of them comprising a POE::Session; all of them share an internal queue of tasks to be performed. Each module performs several tasks on initialization, and if anything goes wrong, croak() is called to stop the service -&gt; this is considered ok, since croak() is only called during initialization, when validation is being performed. <br/>&gt;&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt;&gt; The product is stable and works really fine, but recently I updated POE to the latest version, and since then we can see this message in the logs: <br/>&gt;&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt;&gt; registering pdu failed: 263! <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === 5 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === 5 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === 9 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === 9 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! Kernel has child processes. <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>&gt;&gt;&gt;&gt;&gt; mkdir /mnt/nfs99: Permission denied at Handler/Store.pm line 147 <br/>&gt;&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt;&gt; first lines and last line above are the errors itself, but this part is new since the upgrading: <br/>&gt;&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! Kernel has child processes. <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/>&gt;&gt;&gt;&gt;&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>&gt;&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt;&gt; I can see it everytime the service is stopped because of an unhandled condition, even when POE&#39;s event loop has been already running for ours. It was not visible before, and I can&#39;t get rid of it in any way. I&#39;ve tried different ways to avoid it with no luck. <br/>&gt;&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt;&gt; Any advice or alternative approach on this? <br/>&gt;&gt;&gt;&gt;&gt; <br/>&gt;&gt;&gt;&gt;&gt; Many thanks <br/>&gt;&gt;&gt;&gt;&gt; Alberto <br/>&gt;&gt; <br/>&gt;&gt; <br/>&gt; <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2014/03/msg5082.html Mon, 24 Mar 2014 17:30:55 +0000 Asunto: Re: Slow fork bomb message in latest version of POE by albertocurro <br/>Hi, <br/> <br/> Sorry, but I don&#39;t catch what you exactly mean with &quot;not using sig_child() as intended&quot;. Do you mean calling it from the main session so each child process will be closed properly? <br/> <br/> The issue I have is how to handle unexpected exceptions. Seems they are thrown and raised without control, killing POE&#39;s kernel before in the way. I could be thinking in the timing in the wrong way, though... <br/> <br/> Alberto <br/> <br/>---- Activado lun, 24 mar 2014 16:59:49 +0100 Rocco Caputo&lt;rcaputo@pobox.com&gt; escribi&Atilde;&sup3; ---- <br/> <br/> &gt; You are not using sig_child() as intended. When used as intended, sig_child() will prevent shutdown until the child process has exited and has been reaped. The timing issues you&#39;re worried about should not exist. <br/> &gt; <br/> &gt; -- <br/> &gt; Rocco Caputo &lt;rcaputo@pobox.com&gt; <br/> &gt; <br/> &gt; On Mar 24, 2014, at 11:44, albertocurro &lt;albertocurro@zoho.com&gt; wrote: <br/> &gt; <br/> &gt; &gt; Hi Rocco, <br/> &gt; &gt; <br/> &gt; &gt; many thanks for your quick answer! Unfortunately, the provided solution only works partially. I still have some cases where the &quot;fork bomb&quot; message is here with us :( <br/> &gt; &gt; <br/> &gt; &gt; One of the cases is this one: under some configuration, an instance of nginx is started, so our product writes the configuration file and starts the Nginx instance pointing to that configuration file. BUT, if the configuration file could not be written (directory does not exist, etc), then the error raises, and I&#39;ve not found any way to handle it: <br/> &gt; &gt; <br/> &gt; &gt; DEBUG - Created nginx temporary directory /opt/tmp/pull/instance1 <br/> &gt; &gt; DEBUG - Created nginx configuration directory /opt/etc/pull/instance1 <br/> &gt; &gt; DEBUG - Created nginx log directory /opt/log/pull/instance1 <br/> &gt; &gt; DEBUG - creating nginx configfile for instance 1 in /opt/etc/pull/instance1 <br/> &gt; &gt; === 13991 === !!! Kernel has 1 child process(es). <br/> &gt; &gt; === 13991 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt; === 13991 === !!! Be sure to use sig_child() to reap child processes. <br/> &gt; &gt; === 13991 === !!! In extreme cases, failure to reap child processes has <br/> &gt; &gt; === 13991 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/> &gt; &gt; Could not open file: No such file or directory <br/> &gt; &gt; <br/> &gt; &gt; I&#39;ve added a DIE handler in the main session to try to handle this: <br/> &gt; &gt; <br/> &gt; &gt; $sig_session = POE::Session-&gt;create( <br/> &gt; &gt; inline_states =&gt; { <br/> &gt; &gt; _start =&gt; sub { <br/> &gt; &gt; $_[HEAP]{RELOADED} = 0; <br/> &gt; &gt; $_[KERNEL]-&gt;sig(TERM =&gt; &#39;_sigterm&#39;); <br/> &gt; &gt; $_[KERNEL]-&gt;sig(INT =&gt; &#39;_sigterm&#39;); <br/> &gt; &gt; $_[KERNEL]-&gt;sig(DIE =&gt; &#39;_sigterm&#39;); <br/> &gt; &gt; $_[KERNEL]-&gt;sig(nginx_reload =&gt; &#39;_sig_nginx_reload&#39;); <br/> &gt; &gt; $_[KERNEL]-&gt;alias_set(&#39;sighandler&#39;); <br/> &gt; &gt; }, <br/> &gt; &gt; _sigdie =&gt; sub { <br/> &gt; &gt; print &quot;Handling exception, calling stop&quot;; <br/> &gt; &gt; POE::Kernel-&gt;call($sig_session, &#39;_stop&#39;); <br/> &gt; &gt; }, <br/> &gt; &gt; _stop =&gt; sub { <br/> &gt; &gt; # Reap any existing pid (# 1825119) <br/> &gt; &gt; print &quot;Handling stop&quot;; <br/> &gt; &gt; POE::Kernel-&gt;sig_child(); <br/> &gt; &gt; use POSIX &quot;:sys_wait_h&quot;; <br/> &gt; &gt; 1 while waitpid(WNOHANG, -1) &gt; 0; <br/> &gt; &gt; <br/> &gt; &gt; # Clear signal handlers... <br/> &gt; &gt; $_[KERNEL]-&gt;sig(&#39;TERM&#39;); <br/> &gt; &gt; <br/> &gt; &gt; But, as said above, it&#39;s not working. Checking POE&#39;s code, I can see the message lines are generated in Resources/Signals.pm, under _data_sig_finalize() method (where POE is already doing the same you recommended me, waiting for the pid). <br/> &gt; &gt; <br/> &gt; &gt; But _data_sig_finalize() method is called in Kernel.pm just after unregistered all the signals (Kernel.pm =&gt; _finalize_kernel): <br/> &gt; &gt; <br/> &gt; &gt; my $self = shift; <br/> &gt; &gt; <br/> &gt; &gt; # Disable signal watching since there&#39;s now no place for them to go. <br/> &gt; &gt; foreach ($self-&gt;_data_sig_get_safe_signals()) { <br/> &gt; &gt; $self-&gt;loop_ignore_signal($_); <br/> &gt; &gt; } <br/> &gt; &gt; <br/> &gt; &gt; # Remove the kernel session&#39;s signal watcher. <br/> &gt; &gt; $self-&gt;_data_sig_remove($self-&gt;ID, &quot;IDLE&quot;); <br/> &gt; &gt; <br/> &gt; &gt; # The main loop is done, no matter which event library ran it. <br/> &gt; &gt; # sig before loop so that it clears the signal_pipe file handler <br/> &gt; &gt; $self-&gt;_data_sig_finalize(); <br/> &gt; &gt; $self-&gt;loop_finalize(); <br/> &gt; &gt; <br/> &gt; &gt; Once here, none of my signal handlers in the main session instance would work, as the signals have been unregistered. On an exception (die) while POE::Kernel-&gt;run(), how could I handle it then?? <br/> &gt; &gt; <br/> &gt; &gt; Thanks a lot <br/> &gt; &gt; Alberto <br/> &gt; &gt; <br/> &gt; &gt; <br/> &gt; &gt; <br/> &gt; &gt; <br/> &gt; &gt; ---- Activado lun, 24 mar 2014 13:45:45 +0100 Rocco Caputo escribi&Atilde;&sup3; ---- <br/> &gt; &gt; <br/> &gt; &gt;&gt; Hi, Alberto. <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; At program end time, POE runs a quick waitpid() check for child processes that may have leaked. This check was added after a bug report where POE locked up a server after several days of running. It turned out to be the reporter&#39;s application, but it was hard to debug. <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; Your program seems to have created two processes that it didn&#39;t reap: PIDs 5373 and 5374. The ideal solution is to reap those processes before exiting. Your program can do this using POE::Kernel&#39;s sig_child() method. <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; In some cases, a third-party library will create processes and not properly clean them up. It can be impossible to solve this case without modifying other people&#39;s code. <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; If you just want to ignore the problem, this might do the trick. Put these lines in your last _stop handler. They should reap the processes you&#39;ve leaked before POE&#39;s check: <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; use POSIX &quot;:sys_wait_h&quot;; <br/> &gt; &gt;&gt; 1 while waitpid(WNOHANG, -1) &gt; 0; <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; It&#39;s a bit of a pain, but I think it&#39;s better to explicitly ignore the problem than for it to go unnoticed by default. <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; Please let me know whether that resolves your problem. It may not. For example, the processes may still be open until an object is destroyed at global destruction time. <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; -- <br/> &gt; &gt;&gt; Rocco Caputo <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; On Mar 24, 2014, at 05:46, albertocurro wrote: <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt;&gt; Guys, <br/> &gt; &gt;&gt;&gt; <br/> &gt; &gt;&gt;&gt; We have a product developed using POE as a base framework, with some other tool libraries as log4perl; basically is a forward proxy, composed of several modules, each one of them comprising a POE::Session; all of them share an internal queue of tasks to be performed. Each module performs several tasks on initialization, and if anything goes wrong, croak() is called to stop the service -&gt; this is considered ok, since croak() is only called during initialization, when validation is being performed. <br/> &gt; &gt;&gt;&gt; <br/> &gt; &gt;&gt;&gt; The product is stable and works really fine, but recently I updated POE to the latest version, and since then we can see this message in the logs: <br/> &gt; &gt;&gt;&gt; <br/> &gt; &gt;&gt;&gt; registering pdu failed: 263! <br/> &gt; &gt;&gt;&gt; === 5267 === 5 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/> &gt; &gt;&gt;&gt; === 5267 === 5 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/> &gt; &gt;&gt;&gt; === 5267 === 9 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/> &gt; &gt;&gt;&gt; === 5267 === 9 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/> &gt; &gt;&gt;&gt; === 5267 === !!! Kernel has child processes. <br/> &gt; &gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt;&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt;&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/> &gt; &gt;&gt;&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/> &gt; &gt;&gt;&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/> &gt; &gt;&gt;&gt; mkdir /mnt/nfs99: Permission denied at Handler/Store.pm line 147 <br/> &gt; &gt;&gt;&gt; <br/> &gt; &gt;&gt;&gt; first lines and last line above are the errors itself, but this part is new since the upgrading: <br/> &gt; &gt;&gt;&gt; <br/> &gt; &gt;&gt;&gt; === 5267 === !!! Kernel has child processes. <br/> &gt; &gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt;&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt;&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/> &gt; &gt;&gt;&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/> &gt; &gt;&gt;&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/> &gt; &gt;&gt;&gt; <br/> &gt; &gt;&gt;&gt; I can see it everytime the service is stopped because of an unhandled condition, even when POE&#39;s event loop has been already running for ours. It was not visible before, and I can&#39;t get rid of it in any way. I&#39;ve tried different ways to avoid it with no luck. <br/> &gt; &gt;&gt;&gt; <br/> &gt; &gt;&gt;&gt; Any advice or alternative approach on this? <br/> &gt; &gt;&gt;&gt; <br/> &gt; &gt;&gt;&gt; Many thanks <br/> &gt; &gt;&gt;&gt; Alberto <br/> &gt; <br/> &gt; <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2014/03/msg5081.html Mon, 24 Mar 2014 16:15:29 +0000 Re: Slow fork bomb message in latest version of POE by Rocco Caputo You are not using sig_child() as intended. When used as intended, sig_child() will prevent shutdown until the child process has exited and has been reaped. The timing issues you&#39;re worried about should not exist. <br/> <br/>-- <br/>Rocco Caputo &lt;rcaputo@pobox.com&gt; <br/> <br/>On Mar 24, 2014, at 11:44, albertocurro &lt;albertocurro@zoho.com&gt; wrote: <br/> <br/>&gt; Hi Rocco, <br/>&gt; <br/>&gt; many thanks for your quick answer! Unfortunately, the provided solution only works partially. I still have some cases where the &quot;fork bomb&quot; message is here with us :( <br/>&gt; <br/>&gt; One of the cases is this one: under some configuration, an instance of nginx is started, so our product writes the configuration file and starts the Nginx instance pointing to that configuration file. BUT, if the configuration file could not be written (directory does not exist, etc), then the error raises, and I&#39;ve not found any way to handle it: <br/>&gt; <br/>&gt; DEBUG - Created nginx temporary directory /opt/tmp/pull/instance1 <br/>&gt; DEBUG - Created nginx configuration directory /opt/etc/pull/instance1 <br/>&gt; DEBUG - Created nginx log directory /opt/log/pull/instance1 <br/>&gt; DEBUG - creating nginx configfile for instance 1 in /opt/etc/pull/instance1 <br/>&gt; === 13991 === !!! Kernel has 1 child process(es). <br/>&gt; === 13991 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>&gt; === 13991 === !!! Be sure to use sig_child() to reap child processes. <br/>&gt; === 13991 === !!! In extreme cases, failure to reap child processes has <br/>&gt; === 13991 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>&gt; Could not open file: No such file or directory <br/>&gt; <br/>&gt; I&#39;ve added a DIE handler in the main session to try to handle this: <br/>&gt; <br/>&gt; $sig_session = POE::Session-&gt;create( <br/>&gt; inline_states =&gt; { <br/>&gt; _start =&gt; sub { <br/>&gt; $_[HEAP]{RELOADED} = 0; <br/>&gt; $_[KERNEL]-&gt;sig(TERM =&gt; &#39;_sigterm&#39;); <br/>&gt; $_[KERNEL]-&gt;sig(INT =&gt; &#39;_sigterm&#39;); <br/>&gt; $_[KERNEL]-&gt;sig(DIE =&gt; &#39;_sigterm&#39;); <br/>&gt; $_[KERNEL]-&gt;sig(nginx_reload =&gt; &#39;_sig_nginx_reload&#39;); <br/>&gt; $_[KERNEL]-&gt;alias_set(&#39;sighandler&#39;); <br/>&gt; }, <br/>&gt; _sigdie =&gt; sub { <br/>&gt; print &quot;Handling exception, calling stop&quot;; <br/>&gt; POE::Kernel-&gt;call($sig_session, &#39;_stop&#39;); <br/>&gt; }, <br/>&gt; _stop =&gt; sub { <br/>&gt; # Reap any existing pid (# 1825119) <br/>&gt; print &quot;Handling stop&quot;; <br/>&gt; POE::Kernel-&gt;sig_child(); <br/>&gt; use POSIX &quot;:sys_wait_h&quot;; <br/>&gt; 1 while waitpid(WNOHANG, -1) &gt; 0; <br/>&gt; <br/>&gt; # Clear signal handlers... <br/>&gt; $_[KERNEL]-&gt;sig(&#39;TERM&#39;); <br/>&gt; <br/>&gt; But, as said above, it&#39;s not working. Checking POE&#39;s code, I can see the message lines are generated in Resources/Signals.pm, under _data_sig_finalize() method (where POE is already doing the same you recommended me, waiting for the pid). <br/>&gt; <br/>&gt; But _data_sig_finalize() method is called in Kernel.pm just after unregistered all the signals (Kernel.pm =&gt; _finalize_kernel): <br/>&gt; <br/>&gt; my $self = shift; <br/>&gt; <br/>&gt; # Disable signal watching since there&#39;s now no place for them to go. <br/>&gt; foreach ($self-&gt;_data_sig_get_safe_signals()) { <br/>&gt; $self-&gt;loop_ignore_signal($_); <br/>&gt; } <br/>&gt; <br/>&gt; # Remove the kernel session&#39;s signal watcher. <br/>&gt; $self-&gt;_data_sig_remove($self-&gt;ID, &quot;IDLE&quot;); <br/>&gt; <br/>&gt; # The main loop is done, no matter which event library ran it. <br/>&gt; # sig before loop so that it clears the signal_pipe file handler <br/>&gt; $self-&gt;_data_sig_finalize(); <br/>&gt; $self-&gt;loop_finalize(); <br/>&gt; <br/>&gt; Once here, none of my signal handlers in the main session instance would work, as the signals have been unregistered. On an exception (die) while POE::Kernel-&gt;run(), how could I handle it then?? <br/>&gt; <br/>&gt; Thanks a lot <br/>&gt; Alberto <br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; ---- Activado lun, 24 mar 2014 13:45:45 +0100 Rocco Caputo escribi&oacute; ---- <br/>&gt; <br/>&gt;&gt; Hi, Alberto. <br/>&gt;&gt; <br/>&gt;&gt; At program end time, POE runs a quick waitpid() check for child processes that may have leaked. This check was added after a bug report where POE locked up a server after several days of running. It turned out to be the reporter&#39;s application, but it was hard to debug. <br/>&gt;&gt; <br/>&gt;&gt; Your program seems to have created two processes that it didn&#39;t reap: PIDs 5373 and 5374. The ideal solution is to reap those processes before exiting. Your program can do this using POE::Kernel&#39;s sig_child() method. <br/>&gt;&gt; <br/>&gt;&gt; In some cases, a third-party library will create processes and not properly clean them up. It can be impossible to solve this case without modifying other people&#39;s code. <br/>&gt;&gt; <br/>&gt;&gt; If you just want to ignore the problem, this might do the trick. Put these lines in your last _stop handler. They should reap the processes you&#39;ve leaked before POE&#39;s check: <br/>&gt;&gt; <br/>&gt;&gt; use POSIX &quot;:sys_wait_h&quot;; <br/>&gt;&gt; 1 while waitpid(WNOHANG, -1) &gt; 0; <br/>&gt;&gt; <br/>&gt;&gt; It&#39;s a bit of a pain, but I think it&#39;s better to explicitly ignore the problem than for it to go unnoticed by default. <br/>&gt;&gt; <br/>&gt;&gt; Please let me know whether that resolves your problem. It may not. For example, the processes may still be open until an object is destroyed at global destruction time. <br/>&gt;&gt; <br/>&gt;&gt; -- <br/>&gt;&gt; Rocco Caputo <br/>&gt;&gt; <br/>&gt;&gt; On Mar 24, 2014, at 05:46, albertocurro wrote: <br/>&gt;&gt; <br/>&gt;&gt;&gt; Guys, <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; We have a product developed using POE as a base framework, with some other tool libraries as log4perl; basically is a forward proxy, composed of several modules, each one of them comprising a POE::Session; all of them share an internal queue of tasks to be performed. Each module performs several tasks on initialization, and if anything goes wrong, croak() is called to stop the service -&gt; this is considered ok, since croak() is only called during initialization, when validation is being performed. <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; The product is stable and works really fine, but recently I updated POE to the latest version, and since then we can see this message in the logs: <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; registering pdu failed: 263! <br/>&gt;&gt;&gt; === 5267 === 5 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/>&gt;&gt;&gt; === 5267 === 5 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/>&gt;&gt;&gt; === 5267 === 9 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/>&gt;&gt;&gt; === 5267 === 9 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/>&gt;&gt;&gt; === 5267 === !!! Kernel has child processes. <br/>&gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/>&gt;&gt;&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/>&gt;&gt;&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>&gt;&gt;&gt; mkdir /mnt/nfs99: Permission denied at Handler/Store.pm line 147 <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; first lines and last line above are the errors itself, but this part is new since the upgrading: <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; === 5267 === !!! Kernel has child processes. <br/>&gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt;&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/>&gt;&gt;&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/>&gt;&gt;&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; I can see it everytime the service is stopped because of an unhandled condition, even when POE&#39;s event loop has been already running for ours. It was not visible before, and I can&#39;t get rid of it in any way. I&#39;ve tried different ways to avoid it with no luck. <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; Any advice or alternative approach on this? <br/>&gt;&gt;&gt; <br/>&gt;&gt;&gt; Many thanks <br/>&gt;&gt;&gt; Alberto <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2014/03/msg5080.html Mon, 24 Mar 2014 16:00:11 +0000 Asunto: Re: Slow fork bomb message in latest version of POE by albertocurro Hi again, <br/> <br/> sorry! from the code below, there&#39;s a mistake as DIE signal is linked to _sigterm, while is really pointing to _sigdie; just to clarify it before someone says &quot;it can&#39;t work, you are pointing to the wrong method!&quot; :D <br/> <br/> Alberto <br/> <br/> <br/>---- Activado lun, 24 mar 2014 16:44:36 +0100 albertocurro&lt;albertocurro@zoho.com&gt; escribi&Atilde;&sup3; ---- <br/> <br/> &gt; Hi Rocco, <br/> &gt; <br/> &gt; many thanks for your quick answer! Unfortunately, the provided solution only works partially. I still have some cases where the &quot;fork bomb&quot; message is here with us :( <br/> &gt; <br/> &gt; One of the cases is this one: under some configuration, an instance of nginx is started, so our product writes the configuration file and starts the Nginx instance pointing to that configuration file. BUT, if the configuration file could not be written (directory does not exist, etc), then the error raises, and I&#39;ve not found any way to handle it: <br/> &gt; <br/> &gt; DEBUG - Created nginx temporary directory /opt/tmp/pull/instance1 <br/> &gt; DEBUG - Created nginx configuration directory /opt/etc/pull/instance1 <br/> &gt; DEBUG - Created nginx log directory /opt/log/pull/instance1 <br/> &gt; DEBUG - creating nginx configfile for instance 1 in /opt/etc/pull/instance1 <br/> &gt; === 13991 === !!! Kernel has 1 child process(es). <br/> &gt; === 13991 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/> &gt; === 13991 === !!! Be sure to use sig_child() to reap child processes. <br/> &gt; === 13991 === !!! In extreme cases, failure to reap child processes has <br/> &gt; === 13991 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/> &gt; Could not open file: No such file or directory <br/> &gt; <br/> &gt; I&#39;ve added a DIE handler in the main session to try to handle this: <br/> &gt; <br/> &gt; $sig_session = POE::Session-&gt;create( <br/> &gt; inline_states =&gt; { <br/> &gt; _start =&gt; sub { <br/> &gt; $_[HEAP]{RELOADED} = 0; <br/> &gt; $_[KERNEL]-&gt;sig(TERM =&gt; &#39;_sigterm&#39;); <br/> &gt; $_[KERNEL]-&gt;sig(INT =&gt; &#39;_sigterm&#39;); <br/> &gt; $_[KERNEL]-&gt;sig(DIE =&gt; &#39;_sigterm&#39;); <br/> &gt; $_[KERNEL]-&gt;sig(nginx_reload =&gt; &#39;_sig_nginx_reload&#39;); <br/> &gt; $_[KERNEL]-&gt;alias_set(&#39;sighandler&#39;); <br/> &gt; }, <br/> &gt; _sigdie =&gt; sub { <br/> &gt; print &quot;Handling exception, calling stop&quot;; <br/> &gt; POE::Kernel-&gt;call($sig_session, &#39;_stop&#39;); <br/> &gt; }, <br/> &gt; _stop =&gt; sub { <br/> &gt; # Reap any existing pid (# 1825119) <br/> &gt; print &quot;Handling stop&quot;; <br/> &gt; POE::Kernel-&gt;sig_child(); <br/> &gt; use POSIX &quot;:sys_wait_h&quot;; <br/> &gt; 1 while waitpid(WNOHANG, -1) &gt; 0; <br/> &gt; <br/> &gt; # Clear signal handlers... <br/> &gt; $_[KERNEL]-&gt;sig(&#39;TERM&#39;); <br/> &gt; <br/> &gt; But, as said above, it&#39;s not working. Checking POE&#39;s code, I can see the message lines are generated in Resources/Signals.pm, under _data_sig_finalize() method (where POE is already doing the same you recommended me, waiting for the pid). <br/> &gt; <br/> &gt; But _data_sig_finalize() method is called in Kernel.pm just after unregistered all the signals (Kernel.pm =&gt; _finalize_kernel): <br/> &gt; <br/> &gt; my $self = shift; <br/> &gt; <br/> &gt; # Disable signal watching since there&#39;s now no place for them to go. <br/> &gt; foreach ($self-&gt;_data_sig_get_safe_signals()) { <br/> &gt; $self-&gt;loop_ignore_signal($_); <br/> &gt; } <br/> &gt; <br/> &gt; # Remove the kernel session&#39;s signal watcher. <br/> &gt; $self-&gt;_data_sig_remove($self-&gt;ID, &quot;IDLE&quot;); <br/> &gt; <br/> &gt; # The main loop is done, no matter which event library ran it. <br/> &gt; # sig before loop so that it clears the signal_pipe file handler <br/> &gt; $self-&gt;_data_sig_finalize(); <br/> &gt; $self-&gt;loop_finalize(); <br/> &gt; <br/> &gt; Once here, none of my signal handlers in the main session instance would work, as the signals have been unregistered. On an exception (die) while POE::Kernel-&gt;run(), how could I handle it then?? <br/> &gt; <br/> &gt; Thanks a lot <br/> &gt; Alberto <br/> &gt; <br/> &gt; <br/> &gt; <br/> &gt; <br/> &gt; ---- Activado lun, 24 mar 2014 13:45:45 +0100 Rocco Caputo escribi&Atilde;&sup3; ---- <br/> &gt; <br/> &gt; &gt;Hi, Alberto. <br/> &gt; &gt; <br/> &gt; &gt;At program end time, POE runs a quick waitpid() check for child processes that may have leaked. This check was added after a bug report where POE locked up a server after several days of running. It turned out to be the reporter&#39;s application, but it was hard to debug. <br/> &gt; &gt; <br/> &gt; &gt;Your program seems to have created two processes that it didn&#39;t reap: PIDs 5373 and 5374. The ideal solution is to reap those processes before exiting. Your program can do this using POE::Kernel&#39;s sig_child() method. <br/> &gt; &gt; <br/> &gt; &gt;In some cases, a third-party library will create processes and not properly clean them up. It can be impossible to solve this case without modifying other people&#39;s code. <br/> &gt; &gt; <br/> &gt; &gt;If you just want to ignore the problem, this might do the trick. Put these lines in your last _stop handler. They should reap the processes you&#39;ve leaked before POE&#39;s check: <br/> &gt; &gt; <br/> &gt; &gt;use POSIX &quot;:sys_wait_h&quot;; <br/> &gt; &gt;1 while waitpid(WNOHANG, -1) &gt; 0; <br/> &gt; &gt; <br/> &gt; &gt;It&#39;s a bit of a pain, but I think it&#39;s better to explicitly ignore the problem than for it to go unnoticed by default. <br/> &gt; &gt; <br/> &gt; &gt;Please let me know whether that resolves your problem. It may not. For example, the processes may still be open until an object is destroyed at global destruction time. <br/> &gt; &gt; <br/> &gt; &gt;-- <br/> &gt; &gt;Rocco Caputo <br/> &gt; &gt; <br/> &gt; &gt;On Mar 24, 2014, at 05:46, albertocurro wrote: <br/> &gt; &gt; <br/> &gt; &gt;&gt; Guys, <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; We have a product developed using POE as a base framework, with some other tool libraries as log4perl; basically is a forward proxy, composed of several modules, each one of them comprising a POE::Session; all of them share an internal queue of tasks to be performed. Each module performs several tasks on initialization, and if anything goes wrong, croak() is called to stop the service -&gt; this is considered ok, since croak() is only called during initialization, when validation is being performed. <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; The product is stable and works really fine, but recently I updated POE to the latest version, and since then we can see this message in the logs: <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; registering pdu failed: 263! <br/> &gt; &gt;&gt; === 5267 === 5 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/> &gt; &gt;&gt; === 5267 === 5 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/> &gt; &gt;&gt; === 5267 === 9 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/> &gt; &gt;&gt; === 5267 === 9 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/> &gt; &gt;&gt; === 5267 === !!! Kernel has child processes. <br/> &gt; &gt;&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/> &gt; &gt;&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/> &gt; &gt;&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/> &gt; &gt;&gt; mkdir /mnt/nfs99: Permission denied at Handler/Store.pm line 147 <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; first lines and last line above are the errors itself, but this part is new since the upgrading: <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; === 5267 === !!! Kernel has child processes. <br/> &gt; &gt;&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/> &gt; &gt;&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/> &gt; &gt;&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/> &gt; &gt;&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; I can see it everytime the service is stopped because of an unhandled condition, even when POE&#39;s event loop has been already running for ours. It was not visible before, and I can&#39;t get rid of it in any way. I&#39;ve tried different ways to avoid it with no luck. <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; Any advice or alternative approach on this? <br/> &gt; &gt;&gt; <br/> &gt; &gt;&gt; Many thanks <br/> &gt; &gt;&gt; Alberto <br/> &gt; &gt;&gt; <br/> &gt; &gt; <br/> &gt; &gt; <br/> &gt; <br/> &gt; <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2014/03/msg5079.html Mon, 24 Mar 2014 15:48:21 +0000 Re: Slow fork bomb message in latest version of POE by albertocurro Hi Rocco, <br/> <br/> many thanks for your quick answer! Unfortunately, the provided solution only works partially. I still have some cases where the &quot;fork bomb&quot; message is here with us :( <br/> <br/> One of the cases is this one: under some configuration, an instance of nginx is started, so our product writes the configuration file and starts the Nginx instance pointing to that configuration file. BUT, if the configuration file could not be written (directory does not exist, etc), then the error raises, and I&#39;ve not found any way to handle it: <br/> <br/>DEBUG - Created nginx temporary directory /opt/tmp/pull/instance1 <br/>DEBUG - Created nginx configuration directory /opt/etc/pull/instance1 <br/>DEBUG - Created nginx log directory /opt/log/pull/instance1 <br/>DEBUG - creating nginx configfile for instance 1 in /opt/etc/pull/instance1 <br/>=== 13991 === !!! Kernel has 1 child process(es). <br/>=== 13991 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>=== 13991 === !!! Be sure to use sig_child() to reap child processes. <br/>=== 13991 === !!! In extreme cases, failure to reap child processes has <br/>=== 13991 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>Could not open file: No such file or directory <br/> <br/> I&#39;ve added a DIE handler in the main session to try to handle this: <br/> <br/> $sig_session = POE::Session-&gt;create( <br/> inline_states =&gt; { <br/> _start =&gt; sub { <br/> $_[HEAP]{RELOADED} = 0; <br/> $_[KERNEL]-&gt;sig(TERM =&gt; &#39;_sigterm&#39;); <br/> $_[KERNEL]-&gt;sig(INT =&gt; &#39;_sigterm&#39;); <br/> $_[KERNEL]-&gt;sig(DIE =&gt; &#39;_sigterm&#39;); <br/> $_[KERNEL]-&gt;sig(nginx_reload =&gt; &#39;_sig_nginx_reload&#39;); <br/> $_[KERNEL]-&gt;alias_set(&#39;sighandler&#39;); <br/> }, <br/> _sigdie =&gt; sub { <br/> print &quot;Handling exception, calling stop&quot;; <br/> POE::Kernel-&gt;call($sig_session, &#39;_stop&#39;); <br/> }, <br/> _stop =&gt; sub { <br/> # Reap any existing pid (# 1825119) <br/> print &quot;Handling stop&quot;; <br/> POE::Kernel-&gt;sig_child(); <br/> use POSIX &quot;:sys_wait_h&quot;; <br/> 1 while waitpid(WNOHANG, -1) &gt; 0; <br/> <br/> # Clear signal handlers... <br/> $_[KERNEL]-&gt;sig(&#39;TERM&#39;); <br/> <br/>But, as said above, it&#39;s not working. Checking POE&#39;s code, I can see the message lines are generated in Resources/Signals.pm, under _data_sig_finalize() method (where POE is already doing the same you recommended me, waiting for the pid). <br/> <br/>But _data_sig_finalize() method is called in Kernel.pm just after unregistered all the signals (Kernel.pm =&gt; _finalize_kernel): <br/> <br/> my $self = shift; <br/> <br/> # Disable signal watching since there&#39;s now no place for them to go. <br/> foreach ($self-&gt;_data_sig_get_safe_signals()) { <br/> $self-&gt;loop_ignore_signal($_); <br/> } <br/> <br/> # Remove the kernel session&#39;s signal watcher. <br/> $self-&gt;_data_sig_remove($self-&gt;ID, &quot;IDLE&quot;); <br/> <br/> # The main loop is done, no matter which event library ran it. <br/> # sig before loop so that it clears the signal_pipe file handler <br/> $self-&gt;_data_sig_finalize(); <br/> $self-&gt;loop_finalize(); <br/> <br/> Once here, none of my signal handlers in the main session instance would work, as the signals have been unregistered. On an exception (die) while POE::Kernel-&gt;run(), how could I handle it then?? <br/> <br/> Thanks a lot <br/> Alberto <br/> <br/> <br/> <br/> <br/>---- Activado lun, 24 mar 2014 13:45:45 +0100 Rocco Caputo escribi&Atilde;&sup3; ---- <br/> <br/>&gt;Hi, Alberto. <br/>&gt; <br/>&gt;At program end time, POE runs a quick waitpid() check for child processes that may have leaked. This check was added after a bug report where POE locked up a server after several days of running. It turned out to be the reporter&#39;s application, but it was hard to debug. <br/>&gt; <br/>&gt;Your program seems to have created two processes that it didn&#39;t reap: PIDs 5373 and 5374. The ideal solution is to reap those processes before exiting. Your program can do this using POE::Kernel&#39;s sig_child() method. <br/>&gt; <br/>&gt;In some cases, a third-party library will create processes and not properly clean them up. It can be impossible to solve this case without modifying other people&#39;s code. <br/>&gt; <br/>&gt;If you just want to ignore the problem, this might do the trick. Put these lines in your last _stop handler. They should reap the processes you&#39;ve leaked before POE&#39;s check: <br/>&gt; <br/>&gt;use POSIX &quot;:sys_wait_h&quot;; <br/>&gt;1 while waitpid(WNOHANG, -1) &gt; 0; <br/>&gt; <br/>&gt;It&#39;s a bit of a pain, but I think it&#39;s better to explicitly ignore the problem than for it to go unnoticed by default. <br/>&gt; <br/>&gt;Please let me know whether that resolves your problem. It may not. For example, the processes may still be open until an object is destroyed at global destruction time. <br/>&gt; <br/>&gt;-- <br/>&gt;Rocco Caputo <br/>&gt; <br/>&gt;On Mar 24, 2014, at 05:46, albertocurro wrote: <br/>&gt; <br/>&gt;&gt; Guys, <br/>&gt;&gt; <br/>&gt;&gt; We have a product developed using POE as a base framework, with some other tool libraries as log4perl; basically is a forward proxy, composed of several modules, each one of them comprising a POE::Session; all of them share an internal queue of tasks to be performed. Each module performs several tasks on initialization, and if anything goes wrong, croak() is called to stop the service -&gt; this is considered ok, since croak() is only called during initialization, when validation is being performed. <br/>&gt;&gt; <br/>&gt;&gt; The product is stable and works really fine, but recently I updated POE to the latest version, and since then we can see this message in the logs: <br/>&gt;&gt; <br/>&gt;&gt; registering pdu failed: 263! <br/>&gt;&gt; === 5267 === 5 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/>&gt;&gt; === 5267 === 5 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/>&gt;&gt; === 5267 === 9 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/>&gt;&gt; === 5267 === 9 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/>&gt;&gt; === 5267 === !!! Kernel has child processes. <br/>&gt;&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/>&gt;&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/>&gt;&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>&gt;&gt; mkdir /mnt/nfs99: Permission denied at Handler/Store.pm line 147 <br/>&gt;&gt; <br/>&gt;&gt; first lines and last line above are the errors itself, but this part is new since the upgrading: <br/>&gt;&gt; <br/>&gt;&gt; === 5267 === !!! Kernel has child processes. <br/>&gt;&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>&gt;&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/>&gt;&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/>&gt;&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>&gt;&gt; <br/>&gt;&gt; I can see it everytime the service is stopped because of an unhandled condition, even when POE&#39;s event loop has been already running for ours. It was not visible before, and I can&#39;t get rid of it in any way. I&#39;ve tried different ways to avoid it with no luck. <br/>&gt;&gt; <br/>&gt;&gt; Any advice or alternative approach on this? <br/>&gt;&gt; <br/>&gt;&gt; Many thanks <br/>&gt;&gt; Alberto <br/>&gt;&gt; <br/>&gt; <br/>&gt; <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2014/03/msg5078.html Mon, 24 Mar 2014 15:45:56 +0000 Re: Slow fork bomb message in latest version of POE by Rocco Caputo Hi, Alberto. <br/> <br/>At program end time, POE runs a quick waitpid() check for child processes that may have leaked. This check was added after a bug report where POE locked up a server after several days of running. It turned out to be the reporter&#39;s application, but it was hard to debug. <br/> <br/>Your program seems to have created two processes that it didn&#39;t reap: PIDs 5373 and 5374. The ideal solution is to reap those processes before exiting. Your program can do this using POE::Kernel&#39;s sig_child() method. <br/> <br/>In some cases, a third-party library will create processes and not properly clean them up. It can be impossible to solve this case without modifying other people&#39;s code. <br/> <br/>If you just want to ignore the problem, this might do the trick. Put these lines in your last _stop handler. They should reap the processes you&#39;ve leaked before POE&#39;s check: <br/> <br/>use POSIX &quot;:sys_wait_h&quot;; <br/>1 while waitpid(WNOHANG, -1) &gt; 0; <br/> <br/>It&#39;s a bit of a pain, but I think it&#39;s better to explicitly ignore the problem than for it to go unnoticed by default. <br/> <br/>Please let me know whether that resolves your problem. It may not. For example, the processes may still be open until an object is destroyed at global destruction time. <br/> <br/>-- <br/>Rocco Caputo &lt;rcaputo@pobox.com&gt; <br/> <br/>On Mar 24, 2014, at 05:46, albertocurro &lt;albertocurro@zoho.com&gt; wrote: <br/> <br/>&gt; Guys, <br/>&gt; <br/>&gt; We have a product developed using POE as a base framework, with some other tool libraries as log4perl; basically is a forward proxy, composed of several modules, each one of them comprising a POE::Session; all of them share an internal queue of tasks to be performed. Each module performs several tasks on initialization, and if anything goes wrong, croak() is called to stop the service -&gt; this is considered ok, since croak() is only called during initialization, when validation is being performed. <br/>&gt; <br/>&gt; The product is stable and works really fine, but recently I updated POE to the latest version, and since then we can see this message in the logs: <br/>&gt; <br/>&gt; registering pdu failed: 263! <br/>&gt; === 5267 === 5 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/>&gt; === 5267 === 5 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/>&gt; === 5267 === 9 -&gt; on_handle (from Handler/StoreRemote.pm at 87) <br/>&gt; === 5267 === 9 -&gt; on_retry (from Handler/StoreRemote.pm at 141) <br/>&gt; === 5267 === !!! Kernel has child processes. <br/>&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/>&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/>&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>&gt; mkdir /mnt/nfs99: Permission denied at Handler/Store.pm line 147 <br/>&gt; <br/>&gt; first lines and last line above are the errors itself, but this part is new since the upgrading: <br/>&gt; <br/>&gt; === 5267 === !!! Kernel has child processes. <br/>&gt; === 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt; === 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return. <br/>&gt; === 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return. <br/>&gt; === 5267 === !!! Be sure to use sig_child() to reap child processes. <br/>&gt; === 5267 === !!! In extreme cases, failure to reap child processes has <br/>&gt; === 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems. <br/>&gt; <br/>&gt; I can see it everytime the service is stopped because of an unhandled condition, even when POE&#39;s event loop has been already running for ours. It was not visible before, and I can&#39;t get rid of it in any way. I&#39;ve tried different ways to avoid it with no luck. <br/>&gt; <br/>&gt; Any advice or alternative approach on this? <br/>&gt; <br/>&gt; Many thanks <br/>&gt; Alberto <br/>&gt; <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2014/03/msg5077.html Mon, 24 Mar 2014 12:46:13 +0000 Slow fork bomb message in latest version of POE by albertocurro Guys,<br/><br/> We have a product developed using POE as a base framework, with some other tool libraries as log4perl; basically is a forward proxy, composed of several modules, each one of them comprising a POE::Session; all of them share an internal queue of tasks to be performed. Each module performs several tasks on initialization, and if anything goes wrong, croak() is called to stop the service -&gt; this is considered ok, since croak() is only called during initialization, when validation is being performed.<br/><br/> The product is stable and works really fine, but recently I updated POE to the latest version, and since then we can see this message in the logs:<br/><br/>registering pdu failed: 263!<br/>=== 5267 === 5 -&gt; on_handle (from Handler/StoreRemote.pm at 87)<br/>=== 5267 === 5 -&gt; on_retry (from Handler/StoreRemote.pm at 141)<br/>=== 5267 === 9 -&gt; on_handle (from Handler/StoreRemote.pm at 87)<br/>=== 5267 === 9 -&gt; on_retry (from Handler/StoreRemote.pm at 141)<br/>=== 5267 === !!! Kernel has child processes.<br/>=== 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return.<br/>=== 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return.<br/>=== 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return.<br/>=== 5267 === !!! Be sure to use sig_child() to reap child processes.<br/>=== 5267 === !!! In extreme cases, failure to reap child processes has<br/>=== 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems.<br/>mkdir /mnt/nfs99: Permission denied at Handler/Store.pm line 147<br/><br/>first lines and last line above are the errors itself, but this part is new since the upgrading:<br/><br/>=== 5267 === !!! Kernel has child processes.<br/>=== 5267 === !!! Stopped child process (PID 5373) reaped when POE::Kernel-&gt;run() is ready to return.<br/>=== 5267 === !!! Stopped child process (PID 5374) reaped when POE::Kernel-&gt;run() is ready to return.<br/>=== 5267 === !!! At least one child process is still running when POE::Kernel-&gt;run() is ready to return.<br/>=== 5267 === !!! Be sure to use sig_child() to reap child processes.<br/>=== 5267 === !!! In extreme cases, failure to reap child processes has<br/>=== 5267 === !!! resulted in a slow &#39;fork bomb&#39; that has halted systems.<br/><br/>I can see it everytime the service is stopped because of an unhandled condition, even when POE&#39;s event loop has been already running for ours. It was not visible before, and I can&#39;t get rid of it in any way. I&#39;ve tried different ways to avoid it with no luck.<br/><br/>Any advice or alternative approach on this?<br/><br/>Many thanks<br/>Alberto<br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/03/msg5076.html Mon, 24 Mar 2014 09:46:33 +0000 Custom ClientInputFilter for POE::Component::Server::TCP by Michael R. Davis POE Folks, <br/>I&#39;d like to use POE::Component::Server::TCP to read data from&nbsp;active network sensors but they have a&nbsp;proprietary protocol buffer like format.&nbsp; Is there a&nbsp;way to build a ClientInputFilter with multiple fixed length reads building on each other. <br/>&nbsp; <br/>byte-type, byte-payload-length, payload-of-specified-length <br/>&nbsp; <br/>An&nbsp;example <br/>&nbsp; <br/>&quot;\123\005ABCDE&quot; <br/>&quot;\124\000&quot; <br/>&quot;\125\001A&quot; <br/>&quot;\126\007ABCDEFG&quot; <br/>&nbsp; <br/>There is no &quot;line&quot; separator in the protocol. <br/>&nbsp; <br/>I currently already have a deserializer for each type that I&#39;d like to be able to plug into ClientInput $_[ARG0] somehow; <br/>&nbsp; <br/>In non-POE I just <br/>&nbsp; <br/>my $type=read_byte; <br/>my $length=unpack(&quot;C&quot;, read_byte); <br/>my $payload=read_bytes($length); <br/>my $object=My::Object::Factory-&gt;new(type=&gt;$type, data=&gt;$payload); <br/>&nbsp; <br/>Any pointers and help would be appreciated on how to get from here to there. <br/>Thanks, <br/>Mike <br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5075.html Mon, 24 Feb 2014 15:39:27 +0000 Re: Need help for passing data back and forth data over apersistent SSL TCP socket by kai Thanks for this, works perfectly. And since I had so much trouble <br/>finding examples of working code with SSL authentication and a <br/>persistent connection to pass data over I figured I would post the <br/>working code back so it&#39;s in the archive for others to poke at and <br/>steal. This is mostly just a combo of examples from CPAN and the perl <br/>POE cookbook but it seems to work as I wanted and allows multiple <br/>persistent clients etc. With this sever I am authenticating every <br/>command sent by the client against it&#39;s SSL cert. Probably un-needed <br/>beyond the SSLifying of the initial connection but colour me paranoid.<br/><br/>Server code :<br/><br/>#!/usr/bin/perl<br/><br/> use strict;<br/> use warnings;<br/> use Socket;<br/> use POE qw(<br/> Wheel::SocketFactory<br/> Wheel::ReadWrite<br/> Driver::SysRW<br/> Filter::SSL<br/> Filter::Stackable<br/> Filter::Stream<br/> );<br/><br/><br/>my $serverport = 2001;<br/>my $debug = 1;<br/><br/>POE::Session-&gt;create(<br/> inline_states =&gt; {<br/> _start =&gt; \&amp;parent_start,<br/> _stop =&gt; \&amp;parent_stop,<br/><br/> socket_birth =&gt; \&amp;socket_birth,<br/> socket_death =&gt; \&amp;socket_death,<br/> }<br/>);<br/><br/>sub parent_start {<br/> my $heap = $_[HEAP];<br/> $heap-&gt;{debug} = 1;<br/> if ($heap-&gt;{debug}) { print &quot;= I = Starting POE session and <br/>initialising socket\n&quot;};<br/><br/> $heap-&gt;{listener} = POE::Wheel::SocketFactory-&gt;new(<br/> BindAddress =&gt; &#39;127.0.0.1&#39;,<br/> BindPort =&gt; $serverport,<br/> Reuse =&gt; &#39;yes&#39;,<br/> SuccessEvent =&gt; &#39;socket_birth&#39;,<br/> FailureEvent =&gt; &#39;socket_death&#39;,<br/> );<br/> if ($heap-&gt;{debug}) { print &quot;= I = Socket initialised Waiting for <br/>connections\n&quot;};<br/>}<br/><br/># clean up if we shut down the server<br/>sub parent_stop {<br/> my $heap = $_[HEAP];<br/> delete $heap-&gt;{listener};<br/> delete $heap-&gt;{session};<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;= I = Listener Death!\n&quot;};<br/>}<br/><br/># open the socket for the remote session.<br/>sub socket_birth {<br/> my ($socket, $address, $port) = @_[ARG0, ARG1, ARG2];<br/> $address = inet_ntoa($address);<br/><br/> print &quot;\n= S = Socket birth client connecting\n&quot; if $debug;<br/><br/> POE::Session-&gt;create(<br/> inline_states =&gt; {<br/> _start =&gt; \&amp;socket_success,<br/> _stop =&gt; \&amp;socket_death,<br/><br/> socket_input =&gt; \&amp;socket_input,<br/> socket_death =&gt; \&amp;socket_death,<br/> },<br/> args =&gt; [$socket, $address, $port],<br/> );<br/><br/>}<br/><br/># close the socket session when the user exits.<br/>sub socket_death {<br/> my $heap = $_[HEAP];<br/> if ($heap-&gt;{socket_wheel}) {<br/> print &quot;= S = Socket death, client disconnected\n&quot; if $debug;<br/> delete $heap-&gt;{socket_wheel};<br/> }<br/>}<br/><br/># yay! we sucessfully opened a socket. Set up the session.<br/>sub socket_success {<br/> my ($heap, $kernel, $connected_socket, $address, $port) = <br/>@_[HEAP, KERNEL, ARG0, ARG1, ARG2];<br/><br/><br/> $heap-&gt;{debug} = 1;<br/> print &quot;= I = CONNECTION from $address : $port \n&quot; if <br/>$heap-&gt;{debug};<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;= SSL = Creating SSL Object\n&quot;};<br/> ## make your own certificates to use here. Standard Cert <br/>creation. I used easy-rsa which is part of the openvpn package. Makes it <br/>really easy. As defined here: <br/>http://www.hermann-uwe.de/blog/howto-using-openvpn-on-debian-gnu-linux <br/>to the point of building client1 then you can stop.<br/> $heap-&gt;{sslfilter} = POE::Filter::SSL-&gt;new(<br/> crt =&gt; &#39;keys/server.crt&#39;,<br/> key =&gt; &#39;keys/server.key&#39;,<br/> cacrt =&gt; &#39;keys/ca.crt&#39;,<br/> cipher =&gt; &#39;DHE-RSA-AES256-GCM-SHA384:AES256-SHA&#39;,<br/> debug =&gt; 1,<br/> clientcert =&gt; 1<br/> );<br/> );<br/> $heap-&gt;{socket_wheel} = POE::Wheel::ReadWrite-&gt;new(<br/> Handle =&gt; $connected_socket,<br/> Driver =&gt; POE::Driver::SysRW-&gt;new(),<br/> Filter =&gt; POE::Filter::Stackable-&gt;new(Filters =&gt; [<br/> $heap-&gt;{sslfilter},<br/> POE::Filter::Stream-&gt;new(),<br/> ]),<br/> InputEvent =&gt; &#39;socket_input&#39;,<br/> ErrorEvent =&gt; &#39;socket_death&#39;,<br/> );<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;= SSL = SSL connection <br/>established!\n&quot;};<br/>}<br/><br/>sub socket_input {<br/><br/> my ($heap, $kernel, $buf) = @_[HEAP, KERNEL, ARG0];<br/> my $response;<br/> my $sub;<br/> my (@certid) = ($heap-&gt;{sslfilter}-&gt;clientCertIds());<br/> my $content = &#39;&#39;;<br/> $heap-&gt;{debug} = 1;<br/> chomp($buf);<br/> if ($_[HEAP]-&gt;{debug}) {print &quot;= I = Clint command received : <br/>$buf\n&quot;};<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;= SSL = Authing Client <br/>Command\n&quot;};<br/> if ($heap-&gt;{sslfilter}-&gt;clientCertValid()) {<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;= SSL = Client <br/>Certificate Valid, Authorised\n&quot;};<br/> # this is where you take your input from the client, do <br/>something with it and send something back. I am getting temperature <br/>values and sending them to the client. YMMV<br/> if ($buf eq &quot;temp&quot;) {<br/> $content = `/home/pi/c0de/sht15/temp-munin.py`;<br/> } else {<br/> $content = &quot;Unknown request\n&quot;;<br/> }<br/> my $response = $content;<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;= I = Sending Client <br/>Result: $content\n&quot;};<br/> $heap-&gt;{socket_wheel}-&gt;put($response);<br/> } else {<br/> # User is a bad bad person. No cookie!<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;= SSL = Client <br/>Certificate Invalid! Rejecting command and disconnecting!\n&quot;};<br/> $content = &quot;INVALID CERT! Connection rejected!\n&quot;;<br/> my $response = $content;<br/> $heap-&gt;{socket_wheel}-&gt;put($response);<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;= I = Sending Client <br/>Result: $content\n&quot;};<br/> $kernel-&gt;delay(socket_death =&gt; 1);<br/> }<br/>}<br/><br/>$poe_kernel-&gt;run();<br/>## END OF LINE<br/><br/>Client code:<br/><br/>#!/usr/bin/perl<br/><br/> use warnings;<br/> use strict;<br/><br/> use POE qw(Component::Client::TCP Filter::SSL);<br/><br/> POE::Component::Client::TCP-&gt;new(<br/> RemoteAddress =&gt; &quot;localhost&quot;,<br/> RemotePort =&gt; 2001,<br/> ## make your own certificates to use here. Standard Cert creation. I <br/>used easy-rsa which is part of the openvpn package. Makes it really <br/>easy. As defined here: <br/>http://www.hermann-uwe.de/blog/howto-using-openvpn-on-debian-gnu-linux <br/>to the point of building client1 then you can stop.<br/> Filter =&gt; [ &quot;POE::Filter::SSL&quot;, crt =&gt; &#39;keys/client1.crt&#39;, <br/>key =&gt; &#39;keys/client1.key&#39;, client =&gt; 1 ],<br/> Connected =&gt; sub {<br/> $_[HEAP]-&gt;{next_alarm_time} = int(time()); # Immediately <br/>trigger an alarm<br/> $_[KERNEL]-&gt;alarm(tick =&gt; $_[HEAP]-&gt;{next_alarm_time});<br/><br/> },<br/> ServerInput =&gt; sub {<br/> print &quot;from server: &quot;.$_[ARG0].&quot;\n&quot;;<br/> },<br/> InlineStates =&gt; {<br/> tick =&gt; sub {<br/> #send the server a command server input will <br/>then capture the response while this bit waits 10 seconds and then does <br/>it all again. Thanks to Gunnar on the POE mailing list for help with <br/>this.<br/> my $command = &quot;temp&quot;;<br/> print &quot;Sending to server : $command\n&quot;;<br/> $_[HEAP]{server}-&gt;put($command);<br/> $_[HEAP]-&gt;{next_alarm_time}+=10;<br/> $_[KERNEL]-&gt;alarm(tick =&gt; <br/>$_[HEAP]-&gt;{next_alarm_time});<br/> },<br/> }<br/> );<br/><br/>POE::Kernel-&gt;run();<br/>## END OF LINE<br/><br/>Thanks for the help and I hope this helps someone in the future.<br/><br/>Kai<br/><br/>On 2014-02-21 18:14, Gunnar Strand wrote:<br/>&gt; Hi,<br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; 2014-02-21 1:48 GMT+01:00 &lt;kai@angry-monk.com&gt;:<br/>&gt;&gt; Hi there,<br/>&gt;&gt; <br/>&gt;&gt; I&#39;m trying to write a POE based server/client combo that uses SSL <br/>&gt;&gt; authed<br/>&gt;&gt; persistent connections for comunication between a client and server.<br/>&gt;&gt; <br/>&gt;&gt; Basically I have a server running that listens on port 2001. A client<br/>&gt;&gt; connects to the server. Sets up an SSL connection with client <br/>&gt;&gt; certificate<br/>&gt;&gt; auth and then what I _want_ to happen is that the client then (every <br/>&gt;&gt; 10<br/>&gt;&gt; seconds) asks for new temperature data from the server and is served <br/>&gt;&gt; the<br/>&gt;&gt; current value. I have the client asking in a loop every 10 seconds but <br/>&gt;&gt; the<br/>&gt;&gt; server isn&#39;t triggering and responding past the first connection <br/>&gt;&gt; event. I&#39;m<br/>&gt;&gt; not sure I&#39;m doing this right (tm) can anyone help me? I have some <br/>&gt;&gt; inline<br/>&gt;&gt; comments in the code.<br/>&gt; <br/>&gt; You need to have a look at timers for POE:<br/>&gt; <br/>&gt; http://poe.perl.org/?POE_Cookbook/Recurring_Alarms<br/>&gt; <br/>&gt;&gt; <br/>&gt;&gt; client :<br/>&gt;&gt; <br/>&gt;&gt; #!/usr/bin/perl<br/>&gt;&gt; <br/>&gt;&gt; ### very simple connect to server with auth certs and when connected <br/>&gt;&gt; sends<br/>&gt;&gt; the &quot;temp&quot; command.<br/>&gt;&gt; ### then when it receives input it fires off Server input and wait 10 <br/>&gt;&gt; then<br/>&gt;&gt; sends again. But<br/>&gt;&gt; ### should it trigger a input event again? I think I&#39;m looping in POE<br/>&gt;&gt; incorrectly.<br/>&gt;&gt; <br/>&gt;&gt; ServerInput =&gt; sub {<br/>&gt;&gt; my $command = &quot;temp&quot;;<br/>&gt;&gt; while(1) {<br/>&gt;&gt; print &quot;from server: &quot;.$_[ARG0].&quot;\n&quot;;<br/>&gt;&gt; sleep (10);<br/>&gt;&gt; print &quot;Sending to server : $command\n&quot;;<br/>&gt;&gt; $_[HEAP]{server}-&gt;put($command);<br/>&gt;&gt; }<br/>&gt; <br/>&gt; You are correct that you are &quot;looping&quot; incorrectly. POE is<br/>&gt; event-driven and uses run-to-completion scheduling<br/>&gt; which means that each subroutine must exit before the POE Kernel can<br/>&gt; schedule the next event.<br/>&gt; <br/>&gt; You need to 1) set up a recurring alarm and corresponding event<br/>&gt; handler which sends &quot;$command&quot; to the server,<br/>&gt; and 2) handle data from the server in &quot;ServerInput&quot; and then return<br/>&gt; from the subroutine.<br/>&gt; <br/>&gt; Add an alarm to &quot;Connected&quot;:<br/>&gt; <br/>&gt; $_[HEAP]-&gt;{next_alarm_time} = int(time()); # Immediately<br/>&gt; trigger an alarm<br/>&gt; $_[KERNEL]-&gt;alarm(tick =&gt; $_[HEAP]-&gt;{next_alarm_time});<br/>&gt; <br/>&gt; Add an inline state &quot;tick&quot; event:<br/>&gt; <br/>&gt; tick =&gt; sub {<br/>&gt; my $command = &quot;temp&quot;;<br/>&gt; print &quot;Sending to server : $command\n&quot;;<br/>&gt; $_[HEAP]{server}-&gt;put($command);<br/>&gt; $_[HEAP]-&gt;{next_alarm_time}+=10;<br/>&gt; $_[KERNEL]-&gt;alarm(tick =&gt; $_[HEAP]-&gt;{next_alarm_time});<br/>&gt; },<br/>&gt; <br/>&gt; See <br/>&gt; http://search.cpan.org/dist/POE/lib/POE/Component/Client/TCP.pm#InlineStates<br/>&gt; <br/>&gt; Remove *everything* from the &quot;while&quot; loop except the &quot;print&quot;.<br/>&gt; <br/>&gt; I have never dabbled in SSL, so I can&#39;t verify the server function, but <br/>&gt; perhaps<br/>&gt; POE::Component::Server::TCP could relieve you of some of the socket <br/>&gt; handling<br/>&gt; in the server part.<br/>&gt; <br/>&gt; http://search.cpan.org/~rcaputo/POE/lib/POE/Component/Server/TCP.pm<br/>&gt; <br/>&gt; BR<br/>&gt; Gunnar<br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5074.html Mon, 24 Feb 2014 12:39:32 +0000 Re: POCO IRC Proxy plugin by Celso Barriga OK thanks for the explanation. I think I got, but I have to play around with it, I guess. it sounds very interesting though!!! <br/> <br/> <br/>On Feb 22, 2014, at 7:42 PM, Rocco Caputo &lt;rcaputo@pobox.com&gt; wrote: <br/> <br/>&gt; The docs say it&#39;s a simple bouncer that lets you hide many bots and/or clients behind a single IRC connection. Benefits? <br/>&gt; <br/>&gt; If you&#39;re developing bots that crash a lot, you can hide them behind a stable proxy that doesn&#39;t annoy everyone with frequent reconnections. <br/>&gt; <br/>&gt; If you develop a lot of bots, you can put them all behind one IRC connection. This may keep you from being banned by servers that have low connection limits. <br/>&gt; <br/>&gt; If a channel lets you only have one bot, you can cheat. :) <br/>&gt; <br/>&gt; Other things, only limited by the intersection of the implemented features and your imagination! <br/>&gt; <br/>&gt; -- <br/>&gt; Rocco Caputo &lt;rcaputo@pobox.com&gt; <br/>&gt; <br/>&gt; On Feb 22, 2014, at 15:49, Celso Barriga &lt;cbarriga@gmail.com&gt; wrote: <br/>&gt; <br/>&gt;&gt; Can somebody please tell me what this plugin actually do? I&#39;ve read the docs, and if I understand it correctly, by default, it opens up a random port on localhost (if no bindaddress and binport are specified) where the POCO IRC would then connect to. What&#39;s the advantage of doing this and what does this give me? <br/>&gt;&gt; <br/>&gt;&gt; Thanks in advance. <br/>&gt;&gt; <br/>&gt;&gt; Best regards, <br/>&gt;&gt; Celso <br/>&gt; <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5073.html Sun, 23 Feb 2014 23:13:26 +0000 Re: POCO IRC Proxy plugin by =?UTF-8?B?6rmA7Jyg66+8?= L<br/><br/>On Saturday, February 22, 2014, Rocco Caputo &lt;rcaputo@pobox.com&gt; wrote:<br/><br/>&gt; The docs say it&#39;s a simple bouncer that lets you hide many bots and/or<br/>&gt; clients behind a single IRC connection. Benefits?<br/>&gt;<br/>&gt; If you&#39;re developing bots that crash a lot, you can hide them behind a<br/>&gt; stable proxy that doesn&#39;t annoy everyone with frequent reconnections.<br/>&gt;<br/>&gt; If you develop a lot of bots, you can put them all behind one IRC<br/>&gt; connection. This may keep you from being banned by servers that have low<br/>&gt; connection limits.<br/>&gt;<br/>&gt; If a channel lets you only have one bot, you can cheat. :)<br/>&gt;<br/>&gt; Other things, only limited by the intersection of the implemented features<br/>&gt; and your imagination!<br/>&gt;<br/>&gt; --<br/>&gt; Rocco Caputo &lt;rcaputo@pobox.com &lt;javascript:;&gt;&gt;<br/>&gt;<br/>&gt; On Feb 22, 2014, at 15:49, Celso Barriga &lt;cbarriga@gmail.com&lt;javascript:;&gt;&gt;<br/>&gt; wrote:<br/>&gt;<br/>&gt; &gt; Can somebody please tell me what this plugin actually do? I&#39;ve read the<br/>&gt; docs, and if I understand it correctly, by default, it opens up a random<br/>&gt; port on localhost (if no bindaddress and binport are specified) where the<br/>&gt; POCO IRC would then connect to. What&#39;s the advantage of doing this and what<br/>&gt; does this give me?<br/>&gt; &gt;<br/>&gt; &gt; Thanks in advance.<br/>&gt; &gt;<br/>&gt; &gt; Best regards,<br/>&gt; &gt; Celso<br/>&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5072.html Sun, 23 Feb 2014 00:46:54 +0000 Re: POCO IRC Proxy plugin by Rocco Caputo The docs say it&#39;s a simple bouncer that lets you hide many bots and/or clients behind a single IRC connection. Benefits? <br/> <br/>If you&#39;re developing bots that crash a lot, you can hide them behind a stable proxy that doesn&#39;t annoy everyone with frequent reconnections. <br/> <br/>If you develop a lot of bots, you can put them all behind one IRC connection. This may keep you from being banned by servers that have low connection limits. <br/> <br/>If a channel lets you only have one bot, you can cheat. :) <br/> <br/>Other things, only limited by the intersection of the implemented features and your imagination! <br/> <br/>-- <br/>Rocco Caputo &lt;rcaputo@pobox.com&gt; <br/> <br/>On Feb 22, 2014, at 15:49, Celso Barriga &lt;cbarriga@gmail.com&gt; wrote: <br/> <br/>&gt; Can somebody please tell me what this plugin actually do? I&#39;ve read the docs, and if I understand it correctly, by default, it opens up a random port on localhost (if no bindaddress and binport are specified) where the POCO IRC would then connect to. What&#39;s the advantage of doing this and what does this give me? <br/>&gt; <br/>&gt; Thanks in advance. <br/>&gt; <br/>&gt; Best regards, <br/>&gt; Celso <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5071.html Sun, 23 Feb 2014 00:42:50 +0000 POCO IRC Proxy plugin by Celso Barriga Can somebody please tell me what this plugin actually do? I&#39;ve read the<br/>docs, and if I understand it correctly, by default, it opens up a random<br/>port on localhost (if no bindaddress and binport are specified) where the<br/>POCO IRC would then connect to. What&#39;s the advantage of doing this and what<br/>does this give me?<br/><br/>Thanks in advance.<br/><br/>Best regards,<br/>Celso<br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5070.html Sat, 22 Feb 2014 20:49:33 +0000 Re: Need help for passing data back and forth data over a persistentSSL TCP socket by Gunnar Strand Hi,<br/><br/><br/><br/>2014-02-21 1:48 GMT+01:00 &lt;kai@angry-monk.com&gt;:<br/>&gt; Hi there,<br/>&gt;<br/>&gt; I&#39;m trying to write a POE based server/client combo that uses SSL authed<br/>&gt; persistent connections for comunication between a client and server.<br/>&gt;<br/>&gt; Basically I have a server running that listens on port 2001. A client<br/>&gt; connects to the server. Sets up an SSL connection with client certificate<br/>&gt; auth and then what I _want_ to happen is that the client then (every 10<br/>&gt; seconds) asks for new temperature data from the server and is served the<br/>&gt; current value. I have the client asking in a loop every 10 seconds but the<br/>&gt; server isn&#39;t triggering and responding past the first connection event. I&#39;m<br/>&gt; not sure I&#39;m doing this right (tm) can anyone help me? I have some inline<br/>&gt; comments in the code.<br/><br/>You need to have a look at timers for POE:<br/><br/>http://poe.perl.org/?POE_Cookbook/Recurring_Alarms<br/><br/>&gt;<br/>&gt; client :<br/>&gt;<br/>&gt; #!/usr/bin/perl<br/>&gt;<br/>&gt; ### very simple connect to server with auth certs and when connected sends<br/>&gt; the &quot;temp&quot; command.<br/>&gt; ### then when it receives input it fires off Server input and wait 10 then<br/>&gt; sends again. But<br/>&gt; ### should it trigger a input event again? I think I&#39;m looping in POE<br/>&gt; incorrectly.<br/>&gt;<br/>&gt; ServerInput =&gt; sub {<br/>&gt; my $command = &quot;temp&quot;;<br/>&gt; while(1) {<br/>&gt; print &quot;from server: &quot;.$_[ARG0].&quot;\n&quot;;<br/>&gt; sleep (10);<br/>&gt; print &quot;Sending to server : $command\n&quot;;<br/>&gt; $_[HEAP]{server}-&gt;put($command);<br/>&gt; }<br/><br/>You are correct that you are &quot;looping&quot; incorrectly. POE is<br/>event-driven and uses run-to-completion scheduling<br/>which means that each subroutine must exit before the POE Kernel can<br/>schedule the next event.<br/><br/>You need to 1) set up a recurring alarm and corresponding event<br/>handler which sends &quot;$command&quot; to the server,<br/>and 2) handle data from the server in &quot;ServerInput&quot; and then return<br/>from the subroutine.<br/><br/>Add an alarm to &quot;Connected&quot;:<br/><br/> $_[HEAP]-&gt;{next_alarm_time} = int(time()); # Immediately<br/>trigger an alarm<br/> $_[KERNEL]-&gt;alarm(tick =&gt; $_[HEAP]-&gt;{next_alarm_time});<br/><br/>Add an inline state &quot;tick&quot; event:<br/><br/> tick =&gt; sub {<br/> my $command = &quot;temp&quot;;<br/> print &quot;Sending to server : $command\n&quot;;<br/> $_[HEAP]{server}-&gt;put($command);<br/> $_[HEAP]-&gt;{next_alarm_time}+=10;<br/> $_[KERNEL]-&gt;alarm(tick =&gt; $_[HEAP]-&gt;{next_alarm_time});<br/> },<br/><br/>See http://search.cpan.org/dist/POE/lib/POE/Component/Client/TCP.pm#InlineStates<br/><br/>Remove *everything* from the &quot;while&quot; loop except the &quot;print&quot;.<br/><br/>I have never dabbled in SSL, so I can&#39;t verify the server function, but perhaps<br/>POE::Component::Server::TCP could relieve you of some of the socket handling<br/>in the server part.<br/><br/>http://search.cpan.org/~rcaputo/POE/lib/POE/Component/Server/TCP.pm<br/><br/>BR<br/>Gunnar<br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5069.html Fri, 21 Feb 2014 10:14:07 +0000 Need help for passing data back and forth data over a persistentSSL TCP socket by kai Hi there,<br/><br/>I&#39;m trying to write a POE based server/client combo that uses SSL authed <br/>persistent connections for comunication between a client and server.<br/><br/>Basically I have a server running that listens on port 2001. A client <br/>connects to the server. Sets up an SSL connection with client <br/>certificate auth and then what I _want_ to happen is that the client <br/>then (every 10 seconds) asks for new temperature data from the server <br/>and is served the current value. I have the client asking in a loop <br/>every 10 seconds but the server isn&#39;t triggering and responding past the <br/>first connection event. I&#39;m not sure I&#39;m doing this right (tm) can <br/>anyone help me? I have some inline comments in the code.<br/><br/>client :<br/><br/>#!/usr/bin/perl<br/><br/>### very simple connect to server with auth certs and when connected <br/>sends the &quot;temp&quot; command.<br/>### then when it receives input it fires off Server input and wait 10 <br/>then sends again. But<br/>### should it trigger a input event again? I think I&#39;m looping in POE <br/>incorrectly.<br/><br/> use warnings;<br/> use strict;<br/><br/> use POE qw(Component::Client::TCP Filter::SSL);<br/><br/> POE::Component::Client::TCP-&gt;new(<br/> RemoteAddress =&gt; &quot;localhost&quot;,<br/> RemotePort =&gt; 2001,<br/> Filter =&gt; [ &quot;POE::Filter::SSL&quot;, crt =&gt; &#39;keys/client1.crt&#39;, <br/>key =&gt; &#39;keys/client1.key&#39;, client =&gt; 1 ],<br/> Connected =&gt; sub {<br/> $_[HEAP]{server}-&gt;put(&quot;temp&quot;);<br/><br/> },<br/> ServerInput =&gt; sub {<br/> my $command = &quot;temp&quot;;<br/> while(1) {<br/> print &quot;from server: &quot;.$_[ARG0].&quot;\n&quot;;<br/> sleep (10);<br/> print &quot;Sending to server : $command\n&quot;;<br/> $_[HEAP]{server}-&gt;put($command);<br/> }<br/><br/> },<br/> );<br/><br/> POE::Kernel-&gt;run();<br/> exit;<br/><br/><br/>Server code :<br/><br/>#!/usr/bin/perl<br/><br/> use strict;<br/> use warnings;<br/> use Socket;<br/> use POE qw(<br/> Wheel::SocketFactory<br/> Wheel::ReadWrite<br/> Driver::SysRW<br/> Filter::SSL<br/> Filter::Stackable<br/> Filter::HTTPD<br/> );<br/><br/><br/> POE::Session-&gt;create(<br/> inline_states =&gt; {<br/> _start =&gt; sub {<br/> my $heap = $_[HEAP];<br/> $heap-&gt;{debug} = 1;<br/> if ($heap-&gt;{debug}) { print &quot;Stating POE session and <br/>initialising socket\n&quot;};<br/> $heap-&gt;{listener} = POE::Wheel::SocketFactory-&gt;new(<br/> BindAddress =&gt; &#39;localhost&#39;,<br/> BindPort =&gt; 2001,<br/> Reuse =&gt; &#39;yes&#39;,<br/> SuccessEvent =&gt; &#39;socket_birth&#39;,<br/> FailureEvent =&gt; &#39;_stop&#39;,<br/> );<br/> if ($heap-&gt;{debug}) { print &quot;Socket initialised Waiting for <br/>connections\n&quot;};<br/> },<br/> _stop =&gt; sub {<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;Socket Binding Failed!\n&quot;};<br/> delete $_[HEAP]-&gt;{listener};<br/> },<br/> socket_birth =&gt; sub {<br/> my ($socket) = $_[ARG0];<br/> POE::Session-&gt;create(<br/> inline_states =&gt; {<br/> _start =&gt; sub {<br/> my ($heap, $kernel, $connected_socket, $address, $port) = <br/>@_[HEAP, KERNEL, ARG0, ARG1, ARG2];<br/> $heap-&gt;{debug} = 1;<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;Creating SSL Object\n&quot;};<br/> $heap-&gt;{sslfilter} = POE::Filter::SSL-&gt;new(<br/> crt =&gt; &#39;keys/server.crt&#39;,<br/> key =&gt; &#39;keys/server.key&#39;,<br/> cacrt =&gt; &#39;keys/ca.crt&#39;,<br/> cipher =&gt; &#39;DHE-RSA-AES256-GCM-SHA384:AES256-SHA&#39;,<br/> debug =&gt; 1,<br/> clientcert =&gt; 1<br/> );<br/> $heap-&gt;{socket_wheel} = POE::Wheel::ReadWrite-&gt;new(<br/> Handle =&gt; $connected_socket,<br/> Driver =&gt; POE::Driver::SysRW-&gt;new(),<br/> Filter =&gt; $heap-&gt;{sslfilter},<br/> InputEvent =&gt; &#39;socket_input&#39;,<br/> ErrorEvent =&gt; &#39;_stop&#39;,<br/> );<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;Connection made!\n&quot;};<br/> },<br/> socket_input =&gt; sub {<br/> my ($kernel, $heap, $buf) = @_[KERNEL, HEAP, ARG0];<br/> print &quot;RECEIVE : $buf\n&quot;;<br/> my (@certid) = ($heap-&gt;{sslfilter}-&gt;clientCertIds());<br/> my $content = &#39;&#39;;<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;Authing Client\n&quot;};<br/> if ($heap-&gt;{sslfilter}-&gt;clientCertValid()) {<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;Client Certificate <br/>Valid, Authorised\n&quot;};<br/> if ($buf eq &quot;temp&quot;) {<br/> $content = <br/>`/home/pi/c0de/sht15/temp-munin.py`;<br/> } else {<br/> $content = &quot;Unknown request\n&quot;;<br/> }<br/> my $response = $content;<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;Sending Client <br/>$content\n&quot;};<br/> $heap-&gt;{socket_wheel}-&gt;put($response);<br/> return (1);<br/> #$kernel-&gt;delay(_stop =&gt; 1);<br/> } else {<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;Client Certificate <br/>Invalid, Rejecting connection\n&quot;};<br/> $content .= &quot;INVALID CERT! Connection rejected!\n&quot;;<br/> my $response = $content;<br/> $heap-&gt;{socket_wheel}-&gt;put($response);<br/> $kernel-&gt;delay(_stop =&gt; 1);<br/> }<br/> },<br/> _stop =&gt; sub {<br/> if ($_[HEAP]-&gt;{debug}) { print &quot;Client Disconnected\n&quot;};<br/> delete $_[HEAP]-&gt;{socket_wheel};<br/> }<br/> },<br/> args =&gt; [$socket],<br/> );<br/> }<br/> }<br/> );<br/><br/> $poe_kernel-&gt;run();<br/><br/>Any help anyone can provide would be awesome. I want to avoid <br/>disconnecting and reconnecting ever time I want to get a reading. So <br/>once the connection is made I want to be able to just send a request and <br/>get an answer in an endless loop. I think this should work but can&#39;t <br/>figure out why.<br/><br/>Thanks!<br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5068.html Fri, 21 Feb 2014 00:48:32 +0000 Re: Saving application state by Celso Barriga Thanks guys.<br/><br/>I think I&#39;ll go with Rocco&#39;s suggestion. Since I&#39;ll be reading and writing<br/>probably only 7 to 10 characters, should be no worries about call being<br/>blocked. Besides, I probably want the previous data already in the file<br/>before the next iteration, now that I think about it. And I also like your<br/>suggestion about using File::AtomicWrite.<br/><br/><br/>On Thu, Feb 13, 2014 at 1:37 PM, Rocco Caputo &lt;rcaputo@pobox.com&gt; wrote:<br/><br/>&gt; Hi, Celso.<br/>&gt;<br/>&gt; This isn&#39;t a job for POE.<br/>&gt;<br/>&gt; Use File::AtomicWrite, or something like it, to safely write the time<br/>&gt; stamp as frequently as necessary. It&#39;s a trivial amount of data, so you<br/>&gt; probably don&#39;t need it written asynchronously.<br/>&gt;<br/>&gt; Reload the time stamp when the program restarts.<br/>&gt;<br/>&gt; --<br/>&gt; Rocco Caputo &lt;rcaputo@pobox.com&gt;<br/>&gt;<br/>&gt; On Feb 13, 2014, at 13:21, Celso Barriga &lt;cbarriga@gmail.com&gt; wrote:<br/>&gt;<br/>&gt; &gt; Hello, it&#39;s me again :)<br/>&gt; &gt;<br/>&gt; &gt; I have a POE-based application that queries a web app for some data<br/>&gt; filtered on some time range, say, &quot;send me any changes from time x to now&quot;.<br/>&gt; &gt;<br/>&gt; &gt; The application will be running 24/7, and will query for more changes<br/>&gt; since the last time it asked for changes. I have a tick handler that keeps<br/>&gt; the heartbeat going every second so I can do the query repeatedly.<br/>&gt; &gt;<br/>&gt; &gt; I need to save the last time it made the query in some persistent<br/>&gt; fashion so I can pass it in my next query. I can&#39;t just save it to my heap<br/>&gt; in case the application quits, I need to be able to resume the query since<br/>&gt; the last successful query.<br/>&gt; &gt;<br/>&gt; &gt; What is the best way of doing this, the &quot;POE way&quot;. Can I just save it to<br/>&gt; a file and read it back every tick count, which is 1 sec, using a regular<br/>&gt; file handle?<br/>&gt; &gt;<br/>&gt; &gt; Thanks in advance!<br/>&gt; &gt;<br/>&gt; &gt; Celso<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5067.html Thu, 13 Feb 2014 18:52:42 +0000 Re: Saving application state by Rocco Caputo Hi, Celso. <br/> <br/>This isn&#39;t a job for POE. <br/> <br/>Use File::AtomicWrite, or something like it, to safely write the time stamp as frequently as necessary. It&#39;s a trivial amount of data, so you probably don&#39;t need it written asynchronously. <br/> <br/>Reload the time stamp when the program restarts. <br/> <br/>-- <br/>Rocco Caputo &lt;rcaputo@pobox.com&gt; <br/> <br/>On Feb 13, 2014, at 13:21, Celso Barriga &lt;cbarriga@gmail.com&gt; wrote: <br/> <br/>&gt; Hello, it&#39;s me again :) <br/>&gt; <br/>&gt; I have a POE-based application that queries a web app for some data filtered on some time range, say, &quot;send me any changes from time x to now&quot;. <br/>&gt; <br/>&gt; The application will be running 24/7, and will query for more changes since the last time it asked for changes. I have a tick handler that keeps the heartbeat going every second so I can do the query repeatedly. <br/>&gt; <br/>&gt; I need to save the last time it made the query in some persistent fashion so I can pass it in my next query. I can&#39;t just save it to my heap in case the application quits, I need to be able to resume the query since the last successful query. <br/>&gt; <br/>&gt; What is the best way of doing this, the &quot;POE way&quot;. Can I just save it to a file and read it back every tick count, which is 1 sec, using a regular file handle? <br/>&gt; <br/>&gt; Thanks in advance! <br/>&gt; <br/>&gt; Celso <br/>&gt; <br/>&gt; <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5066.html Thu, 13 Feb 2014 18:39:09 +0000 Saving application state by Celso Barriga Hello, it&#39;s me again :)<br/><br/>I have a POE-based application that queries a web app for some data<br/>filtered on some time range, say, &quot;send me any changes from time x to now&quot;.<br/><br/>The application will be running 24/7, and will query for more changes since<br/>the last time it asked for changes. I have a tick handler that keeps the<br/>heartbeat going every second so I can do the query repeatedly.<br/><br/>I need to save the last time it made the query in some persistent fashion<br/>so I can pass it in my next query. I can&#39;t just save it to my heap in case<br/>the application quits, I need to be able to resume the query since the last<br/>successful query.<br/><br/>What is the best way of doing this, the &quot;POE way&quot;. Can I just save it to a<br/>file and read it back every tick count, which is 1 sec, using a regular<br/>file handle?<br/><br/>Thanks in advance!<br/><br/>Celso<br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5065.html Thu, 13 Feb 2014 18:21:11 +0000 Re: Need advice on a new POE project by Celso Barriga Thank you!<br/><br/>I&#39;m using PoCo::IRC and the basic gut of my app is currently working. It&#39;s<br/>already very feature rich with just about 300 lines of code.<br/><br/>POE Rocks!<br/><br/><br/>On Wed, Feb 12, 2014 at 1:50 AM, Evan Carroll &lt;me@evancarroll.com&gt; wrote:<br/><br/>&gt; Download and install Buubot,<br/>&gt;<br/>&gt; https://github.com/simcop2387/buubot<br/>&gt;<br/>&gt; review the code base and add the plugin that does what you want.<br/>&gt;<br/>&gt; --<br/>&gt; Evan Carroll - me@evancarroll.com<br/>&gt; System Lord of the Internets<br/>&gt; web: http://www.evancarroll.com<br/>&gt; ph: 281.901.0011<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5064.html Wed, 12 Feb 2014 21:34:51 +0000 Re: Need advice on a new POE project by Evan Carroll Download and install Buubot,<br/><br/>https://github.com/simcop2387/buubot<br/><br/>review the code base and add the plugin that does what you want.<br/><br/>-- <br/>Evan Carroll - me@evancarroll.com<br/>System Lord of the Internets<br/>web: http://www.evancarroll.com<br/>ph: 281.901.0011<br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5063.html Wed, 12 Feb 2014 06:51:28 +0000 Re: Need advice on a new POE project by Chris Prather Unless I&#39;m misunderstanding there really isn&#39;t a huge differentiation between your choices here except in &quot;how much work I expect to write myself&quot;. <br/> <br/> <br/> <br/> <br/>I&#39;d start with option 1 since that involves the least amount of work for you personally, and is nearly a proper subset of the others. Then if you run into problems you can escalate to a more complicated solution. <br/> <br/> <br/> <br/> <br/>-Chris <br/> <br/>On Fri, Feb 7, 2014 at 5:54 PM, Celso Barriga &lt;cbarriga@gmail.com&gt; wrote: <br/> <br/>&gt; Hello! <br/>&gt; I just discovered POE while researching on a project I&#39;m about to embark on <br/>&gt; at work. So I&#39;m new with POE, but a long time Perl programmer. I&#39;ve read <br/>&gt; through most of the documentation and tutorial, and now I&#39;m trying to <br/>&gt; decide what approach to take. <br/>&gt; In a nutshell, here&#39;s what my program is supposed to do: <br/>&gt; 0. Log in to an IRC server, at a specified channel. <br/>&gt; 1. Get some data from our web service that has REST interface. But we <br/>&gt; already have a Perl module that wraps the REST calls so I don&#39;t have to <br/>&gt; make the REST calls directly. This perl module is using LWP. <br/>&gt; 2. For each of the data returned from #1, post it to an IRC channel. <br/>&gt; 3. Wait for some predetermined time (say 60 secs?) and go back to #1. <br/>&gt; The data is retrieved through some filter, so there&#39;s not going to be a lot <br/>&gt; of data that will come back. <br/>&gt; The program has to be &quot;mission critical&quot; as much as possible, that is, it <br/>&gt; has to rejoin the channel if kicked out, or reconnect to the server if <br/>&gt; disconnected. <br/>&gt; Here are some of my ideas how I&#39;m going to do it, in order of preference: <br/>&gt; 1. Use POE::Component::IRC to create a bot, and create a recurring alarm <br/>&gt; handler in the tick event. During the tick event is when I retrieve data <br/>&gt; from our web app, and send the messages to the channel. I&#39;m going to use <br/>&gt; the recurring alarm cookbook example in case this will take a while. <br/>&gt; 2. Create two separate sessions similar to the &quot;Combined Services&quot; cookbook <br/>&gt; example. <br/>&gt; 3. Create it from a base POE and create the POE::Sessions myself (instead <br/>&gt; of using the POE::Component::IRC) to handle all the IRC events and second <br/>&gt; POE::Sessions to handle the web app query. <br/>&gt; By going with #1 it will save me a lot of time in handling the IRC events, <br/>&gt; reconnection, etc. But being a noob with POE, I&#39;m wondering if there&#39;s some <br/>&gt; potential problem I&#39;d run into. <br/>&gt; Or is there a better way aside from what I&#39;m thinking? <br/>&gt; Thanks in advance. <br/>&gt; Celso <br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5062.html Sat, 08 Feb 2014 02:03:40 +0000 Need advice on a new POE project by Celso Barriga Hello!<br/><br/>I just discovered POE while researching on a project I&#39;m about to embark on<br/>at work. So I&#39;m new with POE, but a long time Perl programmer. I&#39;ve read<br/>through most of the documentation and tutorial, and now I&#39;m trying to<br/>decide what approach to take.<br/><br/>In a nutshell, here&#39;s what my program is supposed to do:<br/><br/>0. Log in to an IRC server, at a specified channel.<br/><br/>1. Get some data from our web service that has REST interface. But we<br/>already have a Perl module that wraps the REST calls so I don&#39;t have to<br/>make the REST calls directly. This perl module is using LWP.<br/><br/>2. For each of the data returned from #1, post it to an IRC channel.<br/><br/>3. Wait for some predetermined time (say 60 secs?) and go back to #1.<br/><br/>The data is retrieved through some filter, so there&#39;s not going to be a lot<br/>of data that will come back.<br/><br/>The program has to be &quot;mission critical&quot; as much as possible, that is, it<br/>has to rejoin the channel if kicked out, or reconnect to the server if<br/>disconnected.<br/><br/>Here are some of my ideas how I&#39;m going to do it, in order of preference:<br/><br/>1. Use POE::Component::IRC to create a bot, and create a recurring alarm<br/>handler in the tick event. During the tick event is when I retrieve data<br/>from our web app, and send the messages to the channel. I&#39;m going to use<br/>the recurring alarm cookbook example in case this will take a while.<br/><br/>2. Create two separate sessions similar to the &quot;Combined Services&quot; cookbook<br/>example.<br/><br/>3. Create it from a base POE and create the POE::Sessions myself (instead<br/>of using the POE::Component::IRC) to handle all the IRC events and second<br/>POE::Sessions to handle the web app query.<br/><br/>By going with #1 it will save me a lot of time in handling the IRC events,<br/>reconnection, etc. But being a noob with POE, I&#39;m wondering if there&#39;s some<br/>potential problem I&#39;d run into.<br/><br/>Or is there a better way aside from what I&#39;m thinking?<br/><br/>Thanks in advance.<br/><br/>Celso<br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5061.html Fri, 07 Feb 2014 22:54:03 +0000 Re: [SOLVEDish] Problem with MPD client but probably POE user error by Rocco Caputo On Feb 5, 2014, at 16:27, John &lt;john@tonebridge.com&gt; wrote: <br/> <br/>&gt; I added some print statements in POE&#39;s Aliases.pm in the sub <br/>&gt; _data_alias_resolve to see what aliases POE thought existed at any point <br/>&gt; in time. It turns out that at the time _start is executed the mpd alias <br/>&gt; was not registered yet! I figure it is timing and not location. <br/>&gt; <br/>&gt; Anyway, for debugging purposes I added a delayed event and that worked! <br/>&gt; <br/>&gt; I will work with it to get a better understanding if it is timing or <br/>&gt; just having it in _start but it seems I should be good not rushing things. <br/> <br/>I didn&#39;t notice this problem because I expected POE::Component::MPD to set its own alias in its own _start routine. <br/> <br/>_start is called before POE::Session-&gt;create() returns. The predictable timing can be used to avoid problems like this. <br/> <br/>-- <br/>Rocco Caputo &lt;rcaputo@pobox.com&gt; http://www.nntp.perl.org/group/perl.poe/2014/02/msg5060.html Thu, 06 Feb 2014 14:36:19 +0000 [SOLVEDish] Re: Problem with MPD client but probably POE user error by John <br/>&gt; So, based on what I see this doesn&#39;t make much sense. Next step for me<br/>&gt; based on my level of knowledge is to start hacking these to gain some<br/>&gt; insight. If anyone has better direction please let me know.<br/><br/>I added some print statements in POE&#39;s Aliases.pm in the sub <br/>_data_alias_resolve to see what aliases POE thought existed at any point <br/>in time. It turns out that at the time _start is executed the mpd alias <br/>was not registered yet! I figure it is timing and not location.<br/><br/>Anyway, for debugging purposes I added a delayed event and that worked!<br/><br/>I will work with it to get a better understanding if it is timing or <br/>just having it in _start but it seems I should be good not rushing things.<br/><br/>John<br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5059.html Thu, 06 Feb 2014 08:07:54 +0000 Re: Problem with MPD client but probably POE user error by John On 02/05/14 10:36, Nick Perez wrote:<br/>&gt; It has probably failed to connect to mpd. I would make sure you define<br/>&gt; status_msg_to and see that you are actually getting this connected<br/>&gt; event. Also make sure mpd is actually listening where you think it is.<br/>&gt; For example it could be listening on IPv6 localhost.<br/><br/>Thanks...in the code I provided in the original email I think I <br/>addressed these points. Summarizing, when running mpd in the foreground <br/>with verbose logging on I can see the the connect from the client and <br/>the disconnect when I control-c out of the client. The event <br/>&quot;status_msg_to is defined and nothing is sent it.<br/><br/>In the assert output here is the error: &lt;dt&gt; Cannot resolve ``mpd&#39;&#39; into <br/>a session reference.<br/><br/>Digging through the Kernel.pm code, it seems POE is trying to resolve <br/>&#39;mpd&#39; to a session reference through various methods but it cannot. So <br/>I added Dumper output before the attempt to do the post to &#39;mpd&#39;. Based <br/>on my review it does seem like session exists and has correct alias:<br/><br/><br/>$VAR1 = bless( [<br/> {<br/> &#39;1&#39; =&gt; [<br/> bless( [<br/> {<br/> &#39;alias&#39; =&gt; &#39;mpd&#39;<br/> },<br/> {<br/> &#39;default&#39; =&gt; 1<br/> },<br/> {<br/> &#39;_parent&#39; =&gt; [<br/> bless( {<br/> <br/>&#39;session_id&#39; =&gt; 1,<br/> &#39;heap&#39; <br/>=&gt; $VAR1-&gt;[0]{&#39;1&#39;}[0][0]<br/> }, <br/>&#39;POE::Component::Client::MPD&#39; ),<br/> &#39;PARENT&#39;<br/> ],<br/> &#39;mpd_error&#39; =&gt; [<br/> <br/>$VAR1-&gt;[0]{&#39;1&#39;}[0][2]{&#39;_parent&#39;}[0],<br/> &#39;mpd_error&#39;<br/> ],<br/> &#39;mpd_disconnected&#39; =&gt; [<br/> <br/>$VAR1-&gt;[0]{&#39;1&#39;}[0][2]{&#39;_parent&#39;}[0],<br/> <br/>&#39;mpd_disconnected&#39;<br/> ],<br/><br/>[snip]<br/><br/>So, based on what I see this doesn&#39;t make much sense. Next step for me <br/>based on my level of knowledge is to start hacking these to gain some <br/>insight. If anyone has better direction please let me know.<br/><br/>John<br/><br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5058.html Wed, 05 Feb 2014 21:15:11 +0000 Re: Problem with MPD client but probably POE user error by John Thanks!<br/><br/>I updated modules to latest and changed the program since I sent the <br/>original email. Below is output with ASSERT set.<br/><br/>No problem if nothing leaps out as I am still working it.<br/><br/><br/>With POE_ASSERT_DEFAULT=1:<br/><br/>hello there<br/>bye-bye<br/>=== 2437 === Please address any warnings or errors above this message,<br/>=== 2437 === and try again. If there are no previous messages, or they<br/>=== 2437 === are from within POE, then please mail them along with the<br/>=== 2437 === following information to bug-POE@rt.cpan.org:<br/>---<br/>&lt;dt&gt; Cannot resolve ``mpd&#39;&#39; into a session reference<br/>-----<br/> at ./client.pl line 36.<br/> main::start(undef, POE::Session=ARRAY(0x2b3b188), <br/>POE::Kernel=ARRAY(0x15801a0), HASH(0x11e4590), &quot;<br/>_start&quot;, POE::Kernel=ARRAY(0x15801a0), undef, <br/>&quot;/usr/lib64/perl5/site_perl/5.12.4/POE/Kernel.pm&quot;, 1479, ...<br/>) called at /usr/lib64/perl5/site_perl/5.12.4/POE/Session.pm line 464<br/> POE::Session::_invoke_state(POE::Session=ARRAY(0x2b3b188), <br/>POE::Kernel=ARRAY(0x15801a0), &quot;_start&quot;,<br/> ARRAY(0x167b968), &quot;/usr/lib64/perl5/site_perl/5.12.4/POE/Kernel.pm&quot;, <br/>1479, undef) called at /usr/lib64/pe<br/>rl5/site_perl/5.12.4/POE/Kernel.pm line 1067<br/> eval {...} called at <br/>/usr/lib64/perl5/site_perl/5.12.4/POE/Kernel.pm line 1066<br/> POE::Kernel::_dispatch_event(POE::Kernel=ARRAY(0x15801a0), <br/>POE::Session=ARRAY(0x2b3b188), POE::Ses<br/>sion=ARRAY(0x2b3b188), &quot;_start&quot;, 4, ARRAY(0x167b968), <br/>&quot;/usr/lib64/perl5/site_perl/5.12.4/POE/Kernel.pm&quot;, 1<br/>479, undef, ...) called at <br/>/usr/lib64/perl5/site_perl/5.12.4/POE/Kernel.pm line 1476<br/> POE::Kernel::session_alloc(POE::Kernel=ARRAY(0x15801a0), <br/>POE::Session=ARRAY(0x2b3b188)) called at<br/>/usr/lib64/perl5/site_perl/5.12.4/POE/Session.pm line 192<br/> POE::Session::try_alloc(POE::Session=ARRAY(0x2b3b188)) called <br/>at /usr/lib64/perl5/site_perl/5.12.4<br/>/POE/Session.pm line 373<br/> POE::Session::create(&quot;POE::Session&quot;, &quot;inline_states&quot;, <br/>HASH(0x11bffd8)) called at ./client.pl line<br/>24<br/><br/><br/><br/><br/>On 02/04/14 10:24, Rocco Caputo wrote:<br/>&gt; Hi, John.<br/>&gt;<br/>&gt; I don&#39;t see anything obviously wrong in the code you provided. I don&#39;t have MPD, and I&#39;m not familiar with the module you&#39;re using, but I can offer some general POE advice.<br/>&gt;<br/>&gt; POE has some debugging switches, documented in POE::Kernel. I recommend at least enabling: ASSERT_EVENTS, ASSERT_USAGE, and ASSERT_RETVALS. You can do this in your shell:<br/>&gt;<br/>&gt; export POE_ASSERT_EVENTS=1<br/>&gt; export POE_ASSERT_USAGE=1<br/>&gt; export POE_ASSERT_RETVALS=1<br/>&gt;<br/>&gt; Or to turn them all on (and a bit more) in one fell swoop:<br/>&gt;<br/>&gt; export POE_ASSERT_DEFAULT=1<br/>&gt;<br/>&gt; Then run your program. Hopefully POE will warn you about something relevant.<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5057.html Wed, 05 Feb 2014 03:08:13 +0000 Re: Problem with MPD client but probably POE user error by Rocco Caputo Hi, John. <br/> <br/>I don&#39;t see anything obviously wrong in the code you provided. I don&#39;t have MPD, and I&#39;m not familiar with the module you&#39;re using, but I can offer some general POE advice. <br/> <br/>POE has some debugging switches, documented in POE::Kernel. I recommend at least enabling: ASSERT_EVENTS, ASSERT_USAGE, and ASSERT_RETVALS. You can do this in your shell: <br/> <br/>export POE_ASSERT_EVENTS=1 <br/>export POE_ASSERT_USAGE=1 <br/>export POE_ASSERT_RETVALS=1 <br/> <br/>Or to turn them all on (and a bit more) in one fell swoop: <br/> <br/>export POE_ASSERT_DEFAULT=1 <br/> <br/>Then run your program. Hopefully POE will warn you about something relevant. <br/> <br/>-- <br/>Rocco Caputo &lt;rcaputo@pobox.com&gt; <br/> <br/>On Feb 4, 2014, at 07:56, John &lt;john@tonebridge.com&gt; wrote: <br/>&gt; <br/>&gt; none of the events I send get <br/>&gt; to the daemon (also running on localhost with default port). <br/> <br/>&gt; maybe this is not a problem <br/>&gt; with MPD.pm but my usage of POE. <br/>&gt; <br/>&gt; I can use the command line client that comes with MPD to <br/>&gt; interact with the daemon and that works as expected as well as it <br/>&gt; generates logging information. <br/> <br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5056.html Tue, 04 Feb 2014 16:24:50 +0000 Problem with MPD client but probably POE user error by John Hello,<br/><br/>I am working with POE::Component::Client::MPD for the first time and <br/>attempting to get the example provided working. I have modified it <br/>along the way but results have been the same (code is below).<br/><br/>The MPD (Music Player Daemon) logging shows the client connect and <br/>disconnect (when I control-c). However, none of the events I send get <br/>to the daemon (also running on localhost with default port). I added <br/>print statements at pretty much all the entry points for events within <br/>MPD.pm and none of them get hit. Therefore maybe this is not a problem <br/>with MPD.pm but my usage of POE.<br/><br/>Also note that I can use the command line client that comes with MPD to <br/>interact with the daemon and that works as expected as well as it <br/>generates logging information.<br/><br/>Which direction should I go in to track it down?<br/><br/>Thanks,<br/><br/>John<br/><br/>#!/usr/bin/env/perl <br/><br/># <br/><br/><br/>use warnings;<br/>use strict;<br/><br/>use FindBin qw{ $Bin };<br/>use lib &quot;$Bin/../lib&quot;;<br/><br/>use POE;<br/>use POE::Component::Client::MPD;<br/><br/>POE::Component::Client::MPD-&gt;spawn( {<br/> alias =&gt; &#39;mpd&#39;,<br/> } );<br/><br/>POE::Session-&gt;create(<br/> inline_states =&gt; {<br/> _start =&gt; \&amp;start,<br/> _stop =&gt; sub { print &quot;bye-bye\n&quot;; },<br/> mpd_result =&gt; \&amp;result,<br/> mpd_error =&gt; \&amp;error,<br/> status_msgs_to =&gt; \&amp;clutter,<br/> }<br/>);<br/>POE::Kernel-&gt;run;<br/>exit;<br/><br/><br/>sub start {<br/> my $k = $_[KERNEL];<br/> $k-&gt;alias_set(&#39;client&#39;); # increment refcount <br/><br/> print &quot;hello there\n&quot;;<br/> $k-&gt;post( &#39;mpd&#39; =&gt; &#39;current&#39; );<br/> $k-&gt;post( &#39;mpd&#39;, &#39;coll:all_files&#39; );<br/> print &quot;done with start\n&quot;;<br/><br/>}<br/><br/>sub result {<br/> print &quot;yeah!\n&quot;;<br/>}<br/><br/>sub error {<br/> print &quot;got an error\n&quot;;<br/>}<br/><br/>sub clutter {<br/> print &quot;got some clutter!\n&quot;;<br/><br/>}<br/> http://www.nntp.perl.org/group/perl.poe/2014/02/msg5055.html Tue, 04 Feb 2014 14:29:38 +0000 Re: POE HTTP server with WebSocket channel by Guido Brugnara Il 14/12/2013 09:12, Guido Brugnara ha scritto:<br/>&gt; I don&#39;t hide my limit to understand Refrex and derivatives, probably <br/>&gt; because it does not use Moose but only in few occasions, without <br/>&gt; looking under the hood.<br/>&gt;<br/><br/>... because I don&#39;t not use Moose every day, but only ...<br/><br/><br/> http://www.nntp.perl.org/group/perl.poe/2013/12/msg5054.html Sat, 14 Dec 2013 08:17:31 +0000 Re: POE HTTP server with WebSocket channel by Guido Brugnara Il 13/12/2013 10:24, Nick Perez ha scritto:<br/>&gt; Hey Guido,<br/>&gt;<br/>&gt; I am the author of those modules. And yeah, they are broken and<br/>&gt; experimental. I was attempting to create an unholy amalgamation of<br/>&gt; MooseX::Declare and POE. It was an abomination that needed to be killed<br/>&gt; with fire. I should make sure I clean up those modules.<br/>&gt;<br/>&gt; That said, I had started hacking on a replacement stack on top of<br/>&gt; Reflex, but lost interest. You&#39;re welcome to pick it up and finish it<br/>&gt; if that is your cup of tea.<br/>&gt;<br/>&gt; http://nickandperla.net/gitweb/?p=reflexive-role-psgiserver.git<br/><br/>The server is not responding.<br/><br/>&gt;<br/>&gt; It is based on top of Reflexive::Role::TCPServer<br/>&gt;<br/>&gt; https://metacpan.org/pod/Reflexive::Role::TCPServer<br/><br/>I don&#39;t hide my limit to understand Refrex and derivatives, probably <br/>because it does not use Moose but only in few occasions, without looking <br/>under the hood.<br/>I was hoping to avoid the use of modeling alternatives to POE, but if I <br/>have no choice, I will assess this alternative also.<br/><br/>&gt; If you have any questions, feel free to give me a shout on<br/>&gt; irc.perl.org/#poe or #reflex<br/>&gt;<br/>&gt; You can also contact me via XMPP at this same address.<br/><br/>thank you very much<br/>Guido<br/><br/>&gt;<br/>&gt; On Thu, 12 Dec 2013 09:23:54 +0100<br/>&gt; Guido Brugnara &lt;gdo@leader.it&gt; wrote:<br/>&gt;<br/>&gt;&gt; Il 12/12/2013 08:33, Konstantin Yakunin ha scritto:<br/>&gt;&gt;&gt; Hello,<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Try Plack::Builder<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; use Plack::Builder;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; builder {<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; }<br/>&gt;&gt;&gt;<br/>&gt;&gt; I like! Thanks.<br/>&gt;&gt;<br/>&gt;&gt; I tried to install POEx-Role-PSGIServer from CPAN but points out the<br/>&gt;&gt; lack of the package POEx-Role-SessionInstantiation [1]<br/>&gt;&gt; Here ( https://rt.cpan.org/Public/Bug/Display.html?id=69745 ) the<br/>&gt;&gt; author of [1] warns you deleted the package from CPAN because it is<br/>&gt;&gt; no longer compatible with the latest versions of Moose :-(<br/>&gt;&gt; So, The POEx-... packages are all considered experimental/broken?<br/>&gt;&gt; What could I use as a PSGI server, along with POE in a single task?<br/>&gt;&gt; ____<br/>&gt;&gt; gdo<br/>&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; 2013/12/11 Guido Brugnara &lt;gdo@leader.it &lt;mailto:gdo@leader.it&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; ===CUT===<br/>&gt;&gt;&gt; The target is to listen on the same port:<br/>&gt;&gt;&gt; http://myapp:8000/..... and for websocket ws://myapp:8000/ws<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; I tried to use Protocol::WebSocket with the TCP socket used by<br/>&gt;&gt;&gt; PoCo::Server::HTTP but my work is stalled.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; I saw on CPAN that would be available the following packages :<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; POEx::Role::PSGIServer - Encapsulates core PSGI server behaviors<br/>&gt;&gt;&gt; ===CUT===<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;<br/>&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.poe/2013/12/msg5053.html Sat, 14 Dec 2013 08:13:12 +0000 Re: POE HTTP server with WebSocket channel by Nick Perez Hey Guido,<br/><br/>I am the author of those modules. And yeah, they are broken and<br/>experimental. I was attempting to create an unholy amalgamation of<br/>MooseX::Declare and POE. It was an abomination that needed to be killed<br/>with fire. I should make sure I clean up those modules. <br/><br/>That said, I had started hacking on a replacement stack on top of<br/>Reflex, but lost interest. You&#39;re welcome to pick it up and finish it<br/>if that is your cup of tea.<br/><br/>http://nickandperla.net/gitweb/?p=reflexive-role-psgiserver.git<br/><br/>It is based on top of Reflexive::Role::TCPServer<br/><br/>https://metacpan.org/pod/Reflexive::Role::TCPServer<br/><br/>If you have any questions, feel free to give me a shout on<br/>irc.perl.org/#poe or #reflex<br/><br/>You can also contact me via XMPP at this same address.<br/><br/><br/>On Thu, 12 Dec 2013 09:23:54 +0100<br/>Guido Brugnara &lt;gdo@leader.it&gt; wrote:<br/><br/>&gt; Il 12/12/2013 08:33, Konstantin Yakunin ha scritto:<br/>&gt; &gt; Hello,<br/>&gt; &gt;<br/>&gt; &gt; Try Plack::Builder<br/>&gt; &gt;<br/>&gt; &gt; use Plack::Builder;<br/>&gt; &gt;<br/>&gt; &gt; builder {<br/>&gt; &gt;<br/>&gt; &gt; }<br/>&gt; &gt;<br/>&gt; <br/>&gt; I like! Thanks.<br/>&gt; <br/>&gt; I tried to install POEx-Role-PSGIServer from CPAN but points out the <br/>&gt; lack of the package POEx-Role-SessionInstantiation [1]<br/>&gt; Here ( https://rt.cpan.org/Public/Bug/Display.html?id=69745 ) the<br/>&gt; author of [1] warns you deleted the package from CPAN because it is<br/>&gt; no longer compatible with the latest versions of Moose :-(<br/>&gt; So, The POEx-... packages are all considered experimental/broken?<br/>&gt; What could I use as a PSGI server, along with POE in a single task?<br/>&gt; ____<br/>&gt; gdo<br/>&gt; <br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt; 2013/12/11 Guido Brugnara &lt;gdo@leader.it &lt;mailto:gdo@leader.it&gt;&gt;<br/>&gt; &gt;<br/>&gt; &gt; ===CUT===<br/>&gt; &gt; The target is to listen on the same port:<br/>&gt; &gt; http://myapp:8000/..... and for websocket ws://myapp:8000/ws<br/>&gt; &gt;<br/>&gt; &gt; I tried to use Protocol::WebSocket with the TCP socket used by<br/>&gt; &gt; PoCo::Server::HTTP but my work is stalled.<br/>&gt; &gt;<br/>&gt; &gt; I saw on CPAN that would be available the following packages :<br/>&gt; &gt;<br/>&gt; &gt; POEx::Role::PSGIServer - Encapsulates core PSGI server behaviors<br/>&gt; &gt; ===CUT===<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; <br/><br/><br/><br/>-- <br/><br/>Nicholas Perez<br/>XMPP/Email: nick@nickandperla.net<br/>https://metacpan.org/author/NPEREZ<br/>http://github.com/nperez<br/> http://www.nntp.perl.org/group/perl.poe/2013/12/msg5052.html Fri, 13 Dec 2013 09:26:59 +0000 Re: POE HTTP server with WebSocket channel by Guido Brugnara Il 12/12/2013 08:33, Konstantin Yakunin ha scritto:<br/>&gt; Hello,<br/>&gt;<br/>&gt; Try Plack::Builder<br/>&gt;<br/>&gt; use Plack::Builder;<br/>&gt;<br/>&gt; builder {<br/>&gt;<br/>&gt; }<br/>&gt;<br/><br/>I like! Thanks.<br/><br/>I tried to install POEx-Role-PSGIServer from CPAN but points out the <br/>lack of the package POEx-Role-SessionInstantiation [1]<br/>Here ( https://rt.cpan.org/Public/Bug/Display.html?id=69745 ) the author <br/>of [1] warns you deleted the package from CPAN because it is no longer <br/>compatible with the latest versions of Moose :-(<br/>So, The POEx-... packages are all considered experimental/broken?<br/>What could I use as a PSGI server, along with POE in a single task?<br/>____<br/>gdo<br/><br/>&gt;<br/>&gt;<br/>&gt; 2013/12/11 Guido Brugnara &lt;gdo@leader.it &lt;mailto:gdo@leader.it&gt;&gt;<br/>&gt;<br/>&gt; ===CUT===<br/>&gt; The target is to listen on the same port: http://myapp:8000/.....<br/>&gt; and for websocket ws://myapp:8000/ws<br/>&gt;<br/>&gt; I tried to use Protocol::WebSocket with the TCP socket used by<br/>&gt; PoCo::Server::HTTP but my work is stalled.<br/>&gt;<br/>&gt; I saw on CPAN that would be available the following packages :<br/>&gt;<br/>&gt; POEx::Role::PSGIServer - Encapsulates core PSGI server behaviors<br/>&gt; ===CUT===<br/>&gt;<br/>&gt;<br/><br/><br/> http://www.nntp.perl.org/group/perl.poe/2013/12/msg5051.html Thu, 12 Dec 2013 08:24:30 +0000 Re: POE HTTP server with WebSocket channel by Konstantin Yakunin Hello,<br/><br/>Try Plack::Builder<br/><br/>use Plack::Builder;<br/><br/>builder {<br/><br/>}<br/><br/><br/><br/>2013/12/11 Guido Brugnara &lt;gdo@leader.it&gt;<br/><br/>&gt; Hello,<br/>&gt; this is the first time I write in this mail-list, and I hope that the<br/>&gt; question is pertinent. You smile as well for my poor english.<br/>&gt;<br/>&gt; I need to change an application that currently uses Protocol::WebSocket<br/>&gt; and POE::Component::Server::TCP packages so that it can accept from the<br/>&gt; same port even normal HTTP calls.<br/>&gt;<br/>&gt; I currently use POE::Component::Server::HTTP but on a different port (<br/>&gt; http://myapp:8000 and ws://myapp:8001).<br/>&gt;<br/>&gt; The target is to listen on the same port: http://myapp:8000/..... and<br/>&gt; for websocket ws://myapp:8000/ws<br/>&gt;<br/>&gt; I tried to use Protocol::WebSocket with the TCP socket used by<br/>&gt; PoCo::Server::HTTP but my work is stalled.<br/>&gt;<br/>&gt; I saw on CPAN that would be available the following packages :<br/>&gt;<br/>&gt; POEx::Role::PSGIServer - Encapsulates core PSGI server behaviors<br/>&gt;<br/>&gt; Plack::App::WebSocket - WebSocket server as a PSGI application<br/>&gt; or<br/>&gt; method &quot;new_from_psgi&quot; of Protocol::WebSocket::Handshake::Server<br/>&gt;<br/>&gt; Unfortunately I can not find enough documentation to overcome the initial<br/>&gt; impact and achieve at least a first prototype.<br/>&gt;<br/>&gt; If you know of resources such as books, sample code , slides, suggestions<br/>&gt; to help me, please feel free to report them , thank you.<br/>&gt;<br/>&gt; As a&quot;extrema ratio&quot; I can use an external reverse proxy (http and<br/>&gt; websocket ) to aggregate the two services but would like to avoid<br/>&gt; maintaining a single process to manage the application, as it is now .<br/>&gt;<br/>&gt;<br/>&gt; best regards<br/>&gt; gdo<br/>&gt;<br/>&gt; P.S. I use POE for a few years and I will continue to do so for many ...<br/>&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.poe/2013/12/msg5050.html Thu, 12 Dec 2013 07:33:09 +0000 POE HTTP server with WebSocket channel by Guido Brugnara Hello,<br/>this is the first time I write in this mail-list, and I hope that the <br/>question is pertinent. You smile as well for my poor english.<br/><br/>I need to change an application that currently uses Protocol::WebSocket <br/>and POE::Component::Server::TCP packages so that it can accept from the <br/>same port even normal HTTP calls.<br/><br/>I currently use POE::Component::Server::HTTP but on a different port <br/>(http://myapp:8000 and ws://myapp:8001).<br/><br/>The target is to listen on the same port: http://myapp:8000/..... and <br/>for websocket ws://myapp:8000/ws<br/><br/>I tried to use Protocol::WebSocket with the TCP socket used by <br/>PoCo::Server::HTTP but my work is stalled.<br/><br/>I saw on CPAN that would be available the following packages :<br/><br/>POEx::Role::PSGIServer - Encapsulates core PSGI server behaviors<br/><br/>Plack::App::WebSocket - WebSocket server as a PSGI application<br/>or<br/>method &quot;new_from_psgi&quot; of Protocol::WebSocket::Handshake::Server<br/><br/>Unfortunately I can not find enough documentation to overcome the <br/>initial impact and achieve at least a first prototype.<br/><br/>If you know of resources such as books, sample code , slides, <br/>suggestions to help me, please feel free to report them , thank you.<br/><br/>As a&quot;extrema ratio&quot; I can use an external reverse proxy (http and <br/>websocket ) to aggregate the two services but would like to avoid <br/>maintaining a single process to manage the application, as it is now .<br/><br/><br/>best regards<br/>gdo<br/><br/>P.S. I use POE for a few years and I will continue to do so for many ...<br/><br/> http://www.nntp.perl.org/group/perl.poe/2013/12/msg5049.html Wed, 11 Dec 2013 14:38:47 +0000