RE: Robust IKC
[email protected] (Philip Gwyn) Sun, 15 May 2011 23:18:12 -0400
| Newsgroups | perl.poe |
|---|---|
| Message-ID | <[email protected]> |
Hello, IKC creator here. I've been very busy with a few large project and
haven't had the time to look into this properly.
On 06-May-2011 John R. wrote:
> I would like to have my POE client recoever from a variety of IKC
> failure scenarios. For example, detect that the IKC server has gone
> away and reconnect when it joins.
>
> Here is how I call the client:
>
> POE::Component::IKC::Client->spawn(
> host=>'locahost',
> port=>5200,
> name=>'Counter',
> on_error => \&ikc_error,
> on_connect=> sub { Logger->log('counter_gui connected to
> radio') },
> );
>
> POE::Component::IKC::Responder->spawn();
>
> sub ikc_error {
> Logger->log('counter_gui could not connect via IKC to Radio');
> }
>
> However, if the server goes down this handler is not hit either at
> initial drop or when I attempt to post to the remote kernel. It does
> get hit if server is not there at time client is executed.
A disconnecting kernel isn't really an error. You should use 'unregister' to
find out when a remote kernel disconnects.
> $poe_kernel->post('IKC', 'monitor', '*', {
> register=>'remote_register'
> });
>
> sub remote_register {
>
> Logger->log('counter_gui just detected IKC register');
> }
>
> However, this code code does not get hit on a connection (I figured I
> would add unregister later if that was what I needed).
I have a very sneaky suspition that the IKC connection is being set up (and the
register events being sent) before you set up the monitoring.
Monitoring should be set up before spawning a client (or server). Just make
sure the responder is active with
POE::Component::IKC::Responder->spawn()
-Philip