ruby-on-railsrubyxmppgoogle-talkxmpp4r

Ruby Thread Deadlock in XMPP (xmpp4r)


I'm implementing a Google Talk listener that updates me with all my contact list items' presence.

require 'xmpp4r'
require 'xmpp4r/roster'
require 'xmpp4r/roster/helper/roster'

sender_jid = Jabber::JID.new('email')
client = Jabber::Client.new(sender_jid)
client.connect('talk.google.com')
client.auth('password')

client.send(Jabber::Presence.new.set_type(':available'))

#Presence updates:
client.add_presence_callback do |pres|
  puts pres.from.to_s.split("/")[0] unless pres.nil?
  puts pres.show.to_s.inspect unless pres.nil?
end

Thread.stop
client.close

The code works fine and the thread continues to listen on one gmail account but gives me this error after a few contacts appear:

client.rb:33:in `stop': deadlock detected (fatal)
    from client.rb:33:in `<main>'

This other account for which this error appears has a lot more contacts with varying statuses. Can't seem to figure out why this is happening. Any help would be amazing.

Thanks.


Solution

  • Solved the problem through the logger. It was throwing a deadlock because there was a parsing error. There are certain contacts I have with characters that weren't able to get parsed.

    It seems xmpp4r has not been updated in a while and my solution was to move over to a repo that some people have updated.

    If anyone is having a similar problem check out: https://github.com/whitehat101/xmpp4r

    The parsing is done through nokogiri.

    UPDATE: there are a bunch of new maintainers who have forked over many of the updates from above + fixing other issues: https://github.com/xmpp4r/xmpp4r