A: 

You've got resource starvation because of your keepItGoing routine. In general, trying to use XMPP synchronously like this is not going to work. I suggest getting your callbacks set up, then just calling Process() in one loop.

The docs for Process() say:

Process(integer) - takes the timeout period as an argument.  If no
                   timeout is listed then the function blocks until
                   a packet is received.  Otherwise it waits that
                   number of seconds and then exits so your program
                   can continue doing useful things.  NOTE: This is
                   important for GUIs.  You need to leave time to
                   process GUI commands even if you are waiting for
                   packets.  The following are the possible return
                   values, and what they mean:

                       1   - Status ok, data received.
                       0   - Status ok, no data received.
                     undef - Status not ok, stop processing.

                   IMPORTANT: You need to check the output of every
                   Process.  If you get an undef then the connection
                   died and you should behave accordingly.

Each time you call Process(), 0 or more of your callbacks will fire. You never know which, since it depends on server timing. If you want for Process() to return before sending something, you're almost always thinking synchronously, rather than asych, which kills you in XMPP.

In your case, if you remove the call to keepItGoing from chat(), I bet things will work more like you expect.

Joe Hildebrand
@Joe Hildebrand: Can you possibly give or link to a similar example of what you are saying? I am having trouble visualizing the solution. Thanks!
TheGNUGuy
@Joe Hildebrand: If I remove `keepItGoing` from `chat()` then how do I get the script to run continuously until I send a message like "logout?" I guess I am confused about how to make the bot "idle," I thought that was what I was achieving with the `keepItGoing` sub routine. After implementing your suggestion my bot will eventually disconnect from the server because the script exits.
TheGNUGuy
A: 

Replace the line:

$jabberBot->Process(1);

with these:

while (defined($jabberBot->Process(1))) {
    # Do stuff here
}
drew