Question

After connecting to the openfire server with user 'username@localhost' I am trying to create a group chat instant room, so first I send the Presence Stanza as specified here :

<presence from='username@localhost' to='testroom@conference.localhost' xmlns='jabber:client'>
   <x xmlns='http://jabber.org/protocol/muc'></x>
</presence>

But the response is always an error:

<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>

Are there any configurations I have to do to Openfire to get this to work? I know you can create a Group Chat Room with the Openfire Gui, and that works fine, yet when I try to join that Chat Room I get the same exact error.

Was it helpful?

Solution

You need to specify your desired nickname in the room. This is the resource of the JID you send to.

For example, to join the room as 'Joe', send your presence stanza to testroom@conference.localhost/Joe instead of just testroom@conference.localhost.

Your join stanza also should not include a 'from' attribute, this is added for you by the server. Including one doesn't break anything, but it is pointless (and yours is wrong anyway, it must be a full JID).

Therefore a correct stanza for joining the room as 'Joe':

<presence to='testroom@conference.localhost/Joe' xmlns='jabber:client'>
   <x xmlns='http://jabber.org/protocol/muc'/>
</presence>

See XEP-0045: Entering a room for more information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top