I just updated SpeisenJoe and KuerzelKai to reconnect if the server connection was lost :)

The usual problem was, that after doing the servers nightly restart, the bots are also restarted. Sometimes the server came up AFTER the bots, which caused the connection attempt to fail and the bots just flaked out with an exception.

The basic solution was this:

 client = Jabber::Client.new(Jabber::JID.new('user@server/presence'))
 def reconnect(cl)
  cli.connect
  cl.auth('password')
  cl.send(Jabber::Presence.new.set_show(:chat).set_status('lecker essen!'))
  end

 reconnect(client)
 client.on_exception { sleep 5; reconnect(client) }

Found it on the xmpp4r mailing list

Comments