Not logged in. · Lost password · Register
Forum: MatriX RSS
Page:  1  2  next
Avatar
JoeT #1
Member since Oct 2011 · 12 posts
Group memberships: Members
Show profile · Link to this post
Subject: How does one client receive IQ from another?
I have two chat clients that can send messages back and forth and they both are notified of IQ messages via the OnIQ event of the xmpp client when connecting to the server.  But, when I send an IQ like this:

_xmppClient.IqFilter.SendIq(new Iq(toID, fromID, (Matrix.Xmpp.IqType)type, id), new EventHandler<IqEventArgs>(XmppClient_OnIQ));

To "toID" never receives the IQ - is this supposed to work this way?

I've attached two logs, one from each client to show that they connect and can send a message... any help with handling IQ would be appreciated (I had to put both logs in one file apparently). For the record XMPP is pretty new to me...
The author has attached one file to this post:
clients_log.txt 17.7 kBytes
You have no permission to open this file.
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In your log I don't see any custom iq stanza, only the iq stanzas MatriX sends during the login. I see your message stanza and it looks fine.

But what I see in your log is the following:
  1. <iq type="result" id="MX_3" to="xmppjobrecv@jtdev56/MatriX" xmlns="jabber:client">
  2.  <query xmlns="jabber:iq:roster">
  3.     <item jid="xmppjobsender" name="null" subscription="both" />
  4.  </query>
  5. </iq>

the Jid is wrong. It must be xmppjobrecv@jtdev56 instead of xmppjobrecv. This is why you get also presence errors and no presence from this contact. For Iqs you need the presence (resource), because Iqs must be sent always to a full Jid, not to a bare Jid. Try to fix you roster and send the Iqs to a full Jid,then it should work. But don't send them before you got the OnRosterEnd event or the first incoming Presence.

A small hint:
You don't need to set the from attribute on outgoing packets. The server stamps all this packets for you. Because XMPP is a secure protocol and you can't spoof the sender like you can in eg. SMTP.

Alex
Avatar
JoeT #3
Member since Oct 2011 · 12 posts
Group memberships: Members
Show profile · Link to this post
Thank you for the quick reply...

My company is going through the process of trying to approval a license purchase for your library - it is nice to see you responding so quickly on the forums.

I have fixed the roster issue and no longer get the errors about presence.  The first logs there did have a custom IQ sent but it is only one line so easy to miss - scroll all the way to the bottom of the document.  The log attached in the OP is actually two logs in the same file separated by a bunch of white space so you might have missed it.

Here is what it looks like:

  1. <iq to="xmppjobsender@jtdev56" from="xmppjobrecv@jtdev56" type="set" id="bind_1" xmlns="jabber:client" />

and the "xmppjobsender" never receives the IQ.

Attaching fresh log files - test ran after fixing roster JIDs.  NOTE:  attaching two separate log files this time in two separate posts.
The author has attached one file to this post:
xmppjobrecv_log.txt 8.5 kBytes
You have no permission to open this file.
Avatar
JoeT #4
Member since Oct 2011 · 12 posts
Group memberships: Members
Show profile · Link to this post
...and the second log
The author has attached one file to this post:
xmppjobsender_log.txt 8.4 kBytes
You have no permission to open this file.
Avatar
Alex #5
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I missed your iq because I was looking for an iq with payload. A payload is a child tag below the iq tag. Normally iqs always have a payload.

You still send your iq to a bare Jid. Iqs must be sent always to a full jid. And the receiver must be online while you send the iq to him.

Your resource is the default resource "MatriX". So you must send the packet to: xmppjobsender@jtdev56/MatriX and xmppjobrecv@jtdev56/MatriX.

When a server can't deliver an iq then it MUST return an error to you, even when there is no payload and it expects it or improper addressing. Your server never returns an error accoding to your log. This must be a bug in the server.

Please look at the section Extending MatriX in the tutorial. There you can see how you can add your custom payloads to Iqs.

Please let me know if this helps you.

Alex
Avatar
JoeT #6
Member since Oct 2011 · 12 posts
Group memberships: Members
Show profile · Link to this post
Well, made the changes you suggest and followed the tutorial for writing the object derived from XmppElement as well as the complimentary IQ class...

However, when I try to test the code something very strange happens - if I include just this one line in my test app:

Matrix.Xml.Factory.RegisterElement<Bind>(Bind.elementNamespace, Bind.elementName);

then my xmpp server (OpenFire) reports that the user is not online (and the user cannot send or receive messages) despite receiving a login event from Matrix (i.e. it thinks it has successfully connected).  When I remove that line the user is shown as being on line and my two clients can both send and receive messages but, of course, an error is thrown trying to send the IQ.

Any suggestions?
Avatar
JoeT #7
Member since Oct 2011 · 12 posts
Group memberships: Members
Show profile · Link to this post
Here is the client log when I call Factory.Register before connecting
The author has attached one file to this post:
classReg_log.txt 5.3 kBytes
You have no permission to open this file.
Avatar
JoeT #8
Member since Oct 2011 · 12 posts
Group memberships: Members
Show profile · Link to this post
Here is the client log when I do not call Factory.Register before connecting

They look exactly the same to me but definitely have two different out comes on the server...
The author has attached one file to this post:
noClassReg_log.txt 5.3 kBytes
You have no permission to open this file.
Avatar
Alex #9
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Please attach a sample project. There must be something wrong in your codes.

Alex
Avatar
JoeT #10
Member since Oct 2011 · 12 posts
Group memberships: Members
Show profile · Link to this post
No problem.  This Visual Studio 2010 solution should run as is if you have that dev env.  Of course, my xmpp server (domain) and usernames are hardcoded and will have to be changed to whatever you have setup for a server.

In the xmpp_sender project, Program.cs line 19 is the line that registers the Bind class with the factory.  With that line commented out, the sample runs fine for me.  With it executed, the server acts like the users aren't connected (as stated above).
The author has attached one file to this post:
xmpp_dev.zip 375.7 kBytes
You have no permission to open this file.
Avatar
Alex #11
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I looked at your sources.

The problem is that you add a custom element with the namespace urn:ietf:params:xml:ns:xmpp-bind and tagname bind.

Such an element exists already in the XMPP Core RFCs, and is already implemented in the Matrix.Xmpp.Bind.Bind class. When you register a type which already exist you replace the registration of MatriX. The result is that MatriX is not able to bind your resource anymore during the login process.

Why have you chosen this namespace and tag for your custom element? I think there is are uncertainties of the XMPP protocol or the MatriX library. Please let me know how I can clear up this. It would help when you describe your use case and the problem you want to solve here in detail.

Alex
Avatar
JoeT #12
Member since Oct 2011 · 12 posts
Group memberships: Members
Show profile · Link to this post
Well, this is just highlighting my inexperience with XMPP :)

Thanks for the help.  I will contact you further through support channels once my company has purchased a license.
Avatar
Alex #13
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
did you get it working after changing the namespace and/or tagname?

Alex
Avatar
JoeT #14
Member since Oct 2011 · 12 posts
Group memberships: Members
Show profile · Link to this post
I realized that using the Bind class was what I needed.
Avatar
Alex #15
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
so your code is working now?

Alex
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:
Page:  1  2  next
Forum: MatriX RSS