Hello,

I'm sure I'm missing something, but I can't catch it...
I'm using POE::Component::Client::TCP in my application (and also the server component for the server app), and try to implement reconnection after a disconnect. But, when I drop the connection (e. g., kill the server) the client crashes with

"<us> alias does not exist at /usr/local/share/perl/5.10.0/POE/Component/Client/TCP.pm line 290"

(and of course some more POE stuff about the kernel etc.).
I've "solved" the problem by commenting out line 290 in TCP.pm, but obviously, this is not a real solution. Here's the line from TCP.pm which throws the error:

$kernel->alias_remove($alias) if defined $alias;

I've added a print before, and $alias IS defined (I'm using it in my app, see connection setup parameters below). Digging in the code of POE a bit, it seems AFAIK that this error is thrown when the alias to be removed does not belong to the current session. But, I don't have real deep knowledge of POE's inner working, so, I don't know how to fix this, or even, if I've interpreted the error it correctly.

Here's the code snippet I'm using to build the connection:

POE::Component::Client::TCP->new
         ( RemoteAddress => $remotehost,
           RemotePort    => $remoteport,
           ServerInput   => \&handle_input,
           Connected     => \&handle_connect,
           ConnectError  => \&handle_connect_error,
           Disconnected  => \&handle_disconnect,
           Alias         => $conn_alias,
           InlineStates  => {
                              send_msg => \&handle_send_msg,
                            },
         );

And here's my disconnect handler:

sub handle_disconnect {
my $log = Log::Log4perl->get_logger('Statistics.collector.handle_disconnect');
   $log->info ("entering handle_disconnect...");
   my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
   my $session_id = $_[SESSION]->ID;
   $heap->{status} = 1;
   $_[KERNEL]->delay( reconnect => 60 );
   $log->info ("leaving handle_disconnect...");
}

I hope someone can shed some light on this, and tell me how to fix it.

Thanks in advance,

Harald

P.S.: The complete code of the application is online at starcat.sf.net, part "collector_poe.pl", if the snippets are not enough.

Reply via email to