2

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.

murtali
  • 118
  • 1
  • 10
  • What thread are you stopping? You're trying to stop the main thread. That makes no sense. – Linuxios Feb 28 '13 at 00:10
  • The documentation examples and likewise other implementations I've seen all say you need to use Thread.stop at the end. See: (https://github.com/ln/xmpp4r/blob/master/data/doc/xmpp4r/examples/basic/rosterwatch.rb) – murtali Feb 28 '13 at 15:16
  • Thanx bro i got my solution from your question – Jigar Bhatt Jul 15 '14 at 11:58
  • you should checkout the latest maintained library: https://github.com/xmpp4r/xmpp4r – murtali Jul 15 '14 at 19:06

1 Answers1

3

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

murtali
  • 118
  • 1
  • 10