0

我正在尝试使用 xmpp4r 测试向一个 jid 帐户发送消息:

require 'xmpp4r'
include Jabber

jid = JID::new('alice@wonderland.lit')
password = 'secr3t'

cl = Client::new(jid)
cl.connect('166.78.7.179')
cl.auth(password)
cl.send(Presence.new)

to = 'arthur@wonderland.lit'
subject = 'XMPP4R test'
body = 'Hi, this is a XMPP4R test'
m = Message::new( to, body ).set_type(:chat).set_id('1').set_subject(subject)
cl.send m

但我总是得到以下异常:

/home/subout/.rvm/gems/ruby-1.9.3-p374@subout/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:118:in `rescue in auth': closed stream (Jabber::ClientAuthenticationFailure)
   from /home/subout/.rvm/gems/ruby-1.9.3-p374@subout/gems/xmpp4r-0.5/lib/xmpp4r/client.rb:108:in `auth'
   from send_message2.rb:9:in `<main>'
4

1 回答 1

1
  • 首先,请您在此处添加Jabber::debug = true设置cl.connect并在此处发布输出吗?
  • 其次,XMPP 服务器似乎有问题(您确定它在 '166.78.7.179' 运行吗?)
  • 而且,最后但并非最不重要的一点是,您为什么决定使用“过时的”xmpp4r而不是现代的继任者 Blather
于 2013-04-02T12:06:19.573 回答