Custom IQ does not work

Issue #112 closed
Drasko Vrucinic
created an issue

I was following your example of making custom IQ from the following URL : https://sco0ter.bitbucket.io/babbler/customiq.html

And the problem is:

When you send IQ Addition request from requester at the console valid xml is being printed (using ConsoleDebbuger feature attached to XMPPSessionConfiguration).

OUT:

<iq id="52b67734-7e5a-4d10-9920-63db546ac9f5" to="responder@xmpp.serveirc.com/res" type="get"><addition xmlns="http://xmpp.rocks"><summand1>2</summand1><summand2>3</summand2></addition></iq>

and the IN message on the responder side is:

<iq from="requester@xmpp.serveirc.com/res" id="52b67734-7e5a-4d10-9920-63db546ac9f5" to="responder@xmpp.serveirc.com/res" type="get" xml:lang="en-US"><addition xmlns="http://xmpp.rocks"></addition></iq>

As you can see there are no <summand> elements.

I have tested this on Openfire and Ejabberd instances. I've also done some more investigation with the WireShark and it's not about server. Server is just routing the message, which means that the problem is on the client side.

Used babbler0.7.4.jar.
Also tested with libraries from maeven repos.

Comments (13)

  1. Christian Schudt repo owner

    The issue is that the summand field is missing namespace = "rocks:xmpp:sample" in the @XmlElement annotation.

    With Java 8u60 it still works, however with the latest Java 8u141 it doesn't anymore. Seems like JAXB got a little bit more strict.

    I recommend you create a package-info.java in the same package where your JAXB annotated class is, similar as in all other package. Alternatively you can write the namespace attribute in each @XmlElement annotation, but that's a bit cumbersome and less maintainable.

  2. William Munyan

    Hello, I have just started using this library and am trying to create custom IQs. I've also tried implementing the "Addition" IQ extension in my project and receive the error message:

    rocks.xmpp.core.stanza.model.StanzaErrorException: service-unavailable  -  (type 'cancel': do not retry (the error cannot be remedied))
    

    I literally cut/pasted the sample code from the documentation. Here's the output from the console debugger (thank you for that BTW):

    OUT (7jiqc7yrz3): <iq id="a59940f4-702b-485e-b681-42eee2eda1b8" to="jid1@mydomain" type="get"><addition xmlns="http://xmpp.rocks"><summand1>52</summand1><summand2>22</summand2></addition></iq>
    IN (7jiqc7yrz3): <iq from="jid2@mydomain" id="a59940f4-702b-485e-b681-42eee2eda1b8" to="jid1@mydomain/7jiqc7yrz3" type="error"><addition xmlns="http://xmpp.rocks"><summand1>52</summand1><summand2>22</summand2></addition><error type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></service-unavailable></error></iq>

    Thanks for any help!
    -Bill M

  3. William Munyan

    Apparently, you NEED to have a resource in the "to" JID. When I logged in and used "jid1@mydomain/resource" the IQ was exchanged correctly. Any reason why the resource is necessary in this case?

  4. Christian Schudt repo owner

    That's correct. If you don't specify a resource, the IQ is handled by the server and not forwarded to any client.

    That's how it's specified in XMPP.
    See https://xmpp.org/rfcs/rfc6120.html#rules-noto-IQ
    If the IQ stanza is of type "get" or "set" and the server does not understand the namespace that qualifies the payload, the server MUST return an error to the sending entity, which MUST be <service-unavailable/>.

    Contrary, Messages are delivered to the "best" available resource, if you don't specify a resource.

  5. Log in to comment