【发布时间】:2018-01-19 01:17:21
【问题描述】:
我正在开发一个 XMPP 客户端,通过我们自己托管的 ejabberd 社区服务器(版本 17.09)进行通信。
我无法实现 MucSub 功能(据我所知,从 16.08 版开始支持)。
当我发送这个 XML 命令时(在 ejabberd 文档中描述了订阅聊天室):
<iq from='hag66@shakespeare.example'
to='coven@muc.shakespeare.example'
type='set'
id='E6E10350-76CF-40C6-B91B-1EA08C332FC7'>
<subscribe xmlns='urn:xmpp:mucsub:0'
nick='mynick'
password='roompassword'>
<event node='urn:xmpp:mucsub:nodes:messages' />
<event node='urn:xmpp:mucsub:nodes:affiliations' />
<event node='urn:xmpp:mucsub:nodes:subject' />
<event node='urn:xmpp:mucsub:nodes:config' />
</subscribe>
</iq>
(当然要输入此服务器的现有 jid,此聊天室的 allow_subscription 设置为 true)我得到结果:
<iq xml:lang='de'
to='hag66@shakespeare.example'
from='coven@muc.shakespeare.example'
type='error' id='E6E10350-76CF-40C6-B91B-1EA08C332FC7'>
<subscribe xmlns='urn:xmpp:mucsub:0' nick='mynick'>
<event node='urn:xmpp:mucsub:nodes:messages'/>
<event node='urn:xmpp:mucsub:nodes:affiliations'/>
<event node='urn:xmpp:mucsub:nodes:subject'/>
<event node='urn:xmpp:mucsub:nodes:config'/>
</subscribe>
<error code='503' type='cancel'>
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<text xml:lang='de' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>No module is handling this query</text>
</error>
</iq>
当我将查询更改为:
<iq from='hag66@shakespeare.example'
to='coven@muc.shakespeare.example'
type='set'
id='E6E10350-76CF-40C6-B91B-1EA08C332FC7'>
<subscribe xmlns='urn:xmpp:mucsub:0'
nick='mynick'
password='roompassword'>
<event xmlns="http://jabber.org/protocol/pubsub#event" node="urn:xmpp:mucsub:nodes:messages" />
<event xmlns="http://jabber.org/protocol/pubsub#event" node="urn:xmpp:mucsub:nodes:affiliations' />
<event xmlns="http://jabber.org/protocol/pubsub#event" node="urn:xmpp:mucsub:nodes:subject' />
<event xmlns="http://jabber.org/protocol/pubsub#event" node="urn:xmpp:mucsub:nodes:config' />
</subscribe>
</iq>
我得到了结果:
<iq xmlns="jabber:client"
to="hag66@shakespeare.example"
xml:lang="en"
type="result"
from="coven@muc.shakespeare.example"
id="agsXMPP_8">
<subscribe xmlns="urn:xmpp:mucsub:0" nick="mynick" />
</iq>
我将其解释为查询成功。此外,当我查询该用户订阅的聊天室时,会列出该聊天室。
我现在的问题是:无论我使用哪种方法,如果用户不在此聊天室中,则不会收到有关该聊天中消息的通知。
现在最奇怪的是:如果我从服务器获取 DiscoInfo,则未列出 MucSub 功能 (urn:xmpp:mucsub:0),我不明白,因为我的服务器版本支持该功能using and 根据文档默认启用,甚至不能禁用。
有没有人遇到过同样的问题和/或知道如何解决?
提前感谢您的帮助
【问题讨论】: