Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
Walance #1
Member since Jan 2013 · 12 posts
Group memberships: Members
Show profile · Link to this post
Subject: Bad request error in OnPresence event, after entering a room
I have a web application where people can get into a waiting list and social workers can take someone from the waiting list and chat with them. When a social worker does that, a room gets created and the user in the waiting immediately gets invited and the application auto accepts the invite for the user.

We want to move from jabber-net to MatriX, so we're converting our code to use Matrix and while doing that i ran into this problem that i can't seem to fix on my own. So when the room gets created, the user gets automatically invited and then we receive a bad-request error from the server (OpenFire 3.7.1).

This is the xml that gets sent:
<presence to="obecmw01_992246_wxe@conference.chat-test.obec.local" xmlns="jabber:client">
  <x xmlns="http://jabber.org/protocol/muc" />
</presence>

And this is what we receive back:
<presence to="ihv_ytv_992246@chat-test.obec.local/MatriX" from="obecmw01_992246_wxe@conference.chat-test.obec.local" type="error" xmlns="jabber:client">
  <x xmlns="http://jabber.org/protocol/muc" />
  <error code="400" type="modify">
    <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
  </error>
</presence>

This all worked fine with jabber-net, so i probably made some mistake in my conversion, but i can't figure out what.

And if you need more information, here is the full xml log:
http://pastebin.com/vdDqQqxV

// Edit: I have tried different ways to invite users, but i don't really know what the correct way is. There is no example of inviting someone in the mini client or anywhere on this site. I don't understand the difference between DirectInvite and Invite. I have tried them both and so far it seems that i need Invite, but i'm not totally sure. When inviting someone i have to enter the Jid of the room, when i use the Bare Jid i get the error described above. When i use the Jid with the name of the inviter as resource, the inviter gets his own invite and when i use the invitee as resource, i get the following response:

<message to="obecmw01_992246@chat-test.obec.local/MatriX" from="obecmw01_992246_r3h@conference.chat-test.obec.local/ihv_ytv_992246" type="error" xmlns="jabber:client">
  <x xmlns="http://jabber.org/protocol/muc#user">
    <invite to="ihv_ytv_992246@chat-test.obec.local">
      <reason>De chat is nu gestart.</reason>
    </invite>
  </x>
  <error code="404" type="wait">
    <recipient-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
  </error>
</message>

So i'm pretty confused now, could you maybe explain a bit how i'm supposed to invite someone?
This post was edited 2 times, last on 2013-01-23, 17:45 by Walance.
Avatar
Alex #2
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The presence you send to the room does not contain a resource. The resource is the nickname in multi user chat.

example:
room@conferenceserver/Nickname

Alex
Avatar
Walance #3
Member since Jan 2013 · 12 posts
Group memberships: Members
Show profile · Link to this post
Thank you for your answer, could you look at the edit i just made? With "the nickname in multi user chat" do you mean the nickname of the user who created the room and invites the other user, or the nickname of the user that receives the invite?
Avatar
Alex #4
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #2
about the invites, this are just 2 different ways to invite someone to a room.

XEP-0045 defines invites here:
http://xmpp.org/extensions/xep-0045.html#invite

in this case you must be in the room already and then send the invite message to the room. The server broadcasts the message to to the users then.

Direct invitation are defined in XEP-0249:
http://xmpp.org/extensions/xep-0249.html

in this case you send the messages directly from the client to the users you invite.

Both methods have their pros and cons.

see also:
Quote by XEP-0249:
Multi-User Chat [1] defines a protocol for groupchat over XMPP. That specification includes a method for inviting a contact to a room, where the invitation is mediated by the room itself: the user sends the invitation to the room, which in turn sends it to the contact. Unfortunately, a mediated invitation might not be delivered to the contact, for example if the contact blocks communication with entities not in its roster as specified in Privacy Lists [2]. As privacy lists have become more common, MUC invitations have been increasingly blocked at the server side, resulting in an undesirable user experience. Therefore, this specification defines a method for sending an invitation directly from the user to the contact, which re-uses the original 'jabber:x:conference' namespace in use before XEP-0045 was written (with the addition of 'reason', 'continue', and 'thread' attributes for feature parity with mediated invitations).

Your Openfire server does not enforce such rules. So it doesn't matter which invite you use.

Alex
This post was edited on 2013-01-23, 18:19 by Alex.
Avatar
Alex #5
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #3
Quote by Walance:
With "the nickname in multi user chat" do you mean the nickname of the user who created the room and invites the other user, or the nickname of the user that receives the invite?

I guess that the user who sends this Presence wants to join the room. So you must specify a Nickname.
If you Enter the room with the MucManager class this happens all automatically. Just call MucManager.EnterRoom(...)

Alex
Avatar
Walance #6
Member since Jan 2013 · 12 posts
Group memberships: Members
Show profile · Link to this post
I use MucManager.EnterRoom() with a nickname and immediatly after that i pick the first user from the waiting list and call MucManager.Invite(invitee@domain.com, room@conference.domain.com/inviteeNickName, inviteText) to invite that user. Before your answer i didn't add the resource, but now i receive the "recipient-unavailable" error.

Could this maybe be a race condition? Since you said that you have to be in the room before inviting someone else, when i look in my logs i see that the invite gets sent before i receive the message that the room is ready.
Avatar
Alex #7
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by Walance:
I use MucManager.EnterRoom() with a nickname and immediatly after that i pick the first user from the waiting list and call MucManager.Invite(invitee@domain.com, room@conference.domain.com/inviteeNickName, inviteText) to invite that user. Before your answer i didn't add the resource, but now i receive the "recipient-unavailable" error.

this must be:
MucManager.Invite(invitee@domain.com, room@conference.domain.com, inviteText)

seconds parameter is the room jid which has no resource.

Quote by Walance:
Could this maybe be a race condition? Since you said that you have to be in the room before inviting someone else, when i look in my logs i see that the invite gets sent before i receive the message that the room is ready.

yes this can be also a race condition, but the Jid above is wrong. So you should fix this first.
Your logs from pastebin above are very hard to read, I think the logs are coming from different session. We need a separate log file for each session, and the log must be in order.
Avatar
Walance #8
Member since Jan 2013 · 12 posts
Group memberships: Members
Show profile · Link to this post
I removed the resource from the room in the invite and made 2 xml logs, one for each user. You can see the logs here:
http://pastebin.com/nQ0BGXWk
http://pastebin.com/FMeEq2jJ

I added that resource because of this:
The presence you send to the room does not contain a resource. The resource is the nickname in multi user chat.

example:
room@conferenceserver/Nickname

Alex

As far as i know, i don't send that presence manually in my code, so i thought it was the presence of joining the room and thought i could maybe fix it with adding the resource to the invite. Where else do i have to add that resource then? I'm sorry for asking stupid questions :P
Avatar
Alex #9
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In log 1 I see that you:
  • login successful
  • join a room with success
  • send an invite

the invite message is:

  1. <message to="obecmw01_992246_rhn@conference.chat-test.obec.local" xmlns="jabber:client">
  2.  <x xmlns="http://jabber.org/protocol/muc#user">
  3.     <invite to="ihv_iohybiob_992246@chat-test.obec.local">
  4.       <reason>De chat is nu gestart.</reason>
  5.     </invite>
  6.  </x>
  7. </message>

in log 2:
  • you login another user with success
  • and then receive this invite

  1. <message from="obecmw01_992246_rhn@conference.chat-test.obec.local" to="ihv_iohybiob_992246@chat-test.obec.local" xmlns="jabber:client">
  2.  <x xmlns="http://jabber.org/protocol/muc#user">
  3.     <invite from="obecmw01_992246@chat-test.obec.local">
  4.       <reason>De chat is nu gestart.</reason>
  5.     </invite>
  6.  </x>
  7.  <x xmlns="jabber:x:conference" jid="obecmw01_992246_rhn@conference.chat-test.obec.local" />
  8. </message>

But then when you accept this invite from the second client you try to enter the room without a nickname (resource). This is the following presence:

  1. <presence to="obecmw01_992246_rhn@conference.chat-test.obec.local" xmlns="jabber:client">
  2.  <x xmlns="http://jabber.org/protocol/muc" />
  3. </presence>

after this you get the error reply from the server. So add a nickname here and everything should run fine.
Avatar
Walance #10
Member since Jan 2013 · 12 posts
Group memberships: Members
Show profile · Link to this post
Thanks a lot for your help, your solution worked :)

Really, my complements for your awesome support, you answer really fast and give good information :).
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS