我正在尝试使用xmpp4r:
测试发送消息到一个id帐户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>'
- 首先,请添加
Jabber::debug = true
设置在cl.connect
之前和这里的后输出? 第二,看起来XMPP服务器有问题(你确定它运行在"166.78.7.179"?) - 最后但并非最不重要的是,你为什么决定使用"过时的"
xmpp4r
,而不是它的现代继任者Blather
?