bfdi533 has asked for the wisdom of the Perl Monks concerning the following question:

I have a piece of code that I did not write that uses POE to monitor Jabber traffic and log it to a database. From time-to-time (about once a day) the database connection is broken and the software stops functioning. I need to be able to debug this somehow and a) determine what is happening with the MySQL connection and b) make it re-connect on its own rather than having to restart it regularly using cron.

Specifically, the POE modules involved are:

use POE::Preprocessor; use POE qw/ Component::Jabber::Client::J2 Component::Jabber::Error/; use POE::Filter::XML::Node; use POE::Filter::XML::NS qw/ :JABBER :IQ /;

Can anyone give me any pointers on debugging POE code? I know absolutely nothing about POE except that it is message/event based. Beyond that, I haven't a clue on where to start.

Thanks in advance.

Replies are listed 'Best First'.
Re: debugging POE and MySQL connections
by displeaser (Hermit) on Mar 30, 2006 at 11:21 UTC
    Hi,

    Heres a link to a POE site. Contains a cookbook, FAQ and the POE Docs:
    http://poe.perl.org/?What_POE_Is

    Here's a link on the site above to POE_Debug, it may be useful for you:
    http://poe.perl.org/?POE_RFCs/POE_Debug

    Hope this Helps.
    Displeaser.
Re: debugging POE and MySQL connections
by rcaputo (Chaplain) on Mar 30, 2006 at 16:57 UTC

    POE seems like a red herring here. None of the POE modules you mentioned deals with databases, so you're looking at a straightforward DBI issue in a POE-based bot.

    So I'd start by checking and logging the return values from your DBI calls, and graduate to reconnecting and retrying if they fail due to a dropped connection.

    -- Rocco Caputo - http://poe.perl.org/

      Thanks for the pointer; I had not thought about that.

      I dug further and found I could do the following and it would automatically reconnect:

      $dbh = DBI->connect("DBI:mysql:database=$dbname:$server", $username, $password); $dbh->{mysql_auto_reconnect} = 1;