Openfire XMPP MUC创建群聊室错误

Ram*_*ovi 1 xmpp openfire strophe

使用用户'username @ localhost'连接到openfire服务器后,我正在尝试创建一个群聊即时空间,所以首先我按照此处的指定发送Presence Stanza:

<presence from='username@localhost' to='testroom@conference.localhost' xmlns='jabber:client'>
   <x xmlns='http://jabber.org/protocol/muc'></x>
</presence>
Run Code Online (Sandbox Code Playgroud)

但是响应始终是一个错误:

<presence ... from='testroom@conference.localhost type='error'>
    <x xmlns='http://jabber.org/protocol/muc></x>
    <error code='400' type='modify'>
          <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanza"></bad-request>
    </error>
</presence>
Run Code Online (Sandbox Code Playgroud)

我是否需要对Openfire进行任何配置才能使其正常工作?我知道你可以用Openfire Gui创建一个群聊室,并且工作正常,但当我尝试加入聊天室时,我得到了同样的错误.

Mat*_*ttJ 6

您需要在房间中指定所需的昵称.这是您发送给的JID的资源.

例如,要以'Joe'的身份加入房间,请将您的状态节发送给testroom@conference.localhost/Joe而不仅仅是testroom@conference.localhost.

您的加入节也不应包含'from'属性,这是服务器为您添加的.包括一个不会破坏任何东西,但它是毫无意义的(无论如何你的错误,它必须是一个完整的JID).

因此,正确的节以'乔'的身份加入房间:

<presence to='testroom@conference.localhost/Joe' xmlns='jabber:client'>
   <x xmlns='http://jabber.org/protocol/muc'/>
</presence>
Run Code Online (Sandbox Code Playgroud)

请参阅XEP-0045:进入房间以获取更多信息.