【问题标题】:Can't send a message from xmpp4r?无法从 xmpp4r 发送消息?
【发布时间】:2013-03-23 10:45:37
【问题描述】:

我正在尝试使用 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>'

【问题讨论】:

    标签: ruby xmpp messaging xmpp4r


    【解决方案1】:
    • 首先,请您添加Jabber::debug = true设置 在cl.connect 之前并在此处发布输出?
    • 其次,XMPP 服务器似乎有问题(你确定它运行在 '166.78.7.179'?)
    • 最后但并非最不重要的一点是,您为什么要决定 使用“过时的”xmpp4r 而不是它的现代继任者 Blather?

    【讨论】:

    • 从 Vines 切换到 ejabberd 后,它工作正常。我也想试试 Blather,但是如何发送简单的消息而不被 EventMachine 阻塞?
    • Vines 有一些问题,是的。 Vines 代理代码充满了发送非阻塞节 w/EM 的示例。
    • @mudasobwa 现在查看 vines 代理代码,但如果您能指出这样的示例,我将不胜感激。
    • @gduq 举个例子?官方Blather page 提供了简单的 6 行 echo-bot 示例(滚动到“示例”。)
    • @mudasobwa 我正试图让 Blather 在 Windows 上运行,但 EM 存在 5 年的问题,它阻止它建立加密连接。 xmpp4r 几乎没有文档或示例。我发现的那些是错误的或过时的,并且不再在当前版本上运行。有什么建议可以尝试吗?
    猜你喜欢
    • 2023-03-10
    • 2013-09-15
    • 2011-06-25
    • 2017-04-10
    • 2021-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多