Monitoring plugin returns invalid xml response when querying message archive

Hi everyone,

our company is running Openfire 4.0.1 together with the Monitoring Service plugin 1.5.0.

I am currently writing a webchat using the Strophe.js Javascript library and am having some issues when querying the message archive. Concretely, I am sending the following IQ stanza, in order to retrieve all messages of the current user according to XEP-0313:

   <query xmlns="urn:xmpp:mam:0">

        <x xmlns="jabber:x:data" type="submit">

             <field var="FORM_TYPE" type="hidden">

                  <value>urn:xmpp:mam:0</value>

             </field>

        </x>

        <set xmlns="http://jabber.org/protocol/rsm"/>

   </query>

However, Strophe always throws a “badformat” error when parsing the result body. While analyzing the issue, I noticed that this is most likely due to an invalid XML response that is returned by the Monitoring Service plugin. The result of the above mentioned IQ stanza looks as follows:

[previous 7 messages]

   <result xmlns="urn:xmpp:mam:0" id="238">

        <forwarded xmlns="urn:xmpp:forward:0">

             <delay xmlns="urn:xmpp:delay" stamp="2016-02-14T02:09:59.073Z"/>

             <message xmlns="" to="xmpp_1@mydomain" type="chat" from="xmpp_526@mydomain/65wiba29w4">

                  <body>test message</body>

                  <active xmlns="http://jabber.org/protocol/chatstates"/>

             </message>

        </forwarded>

   </result>
   <fin **xmlns="jabber:client"  xmlns="urn:xmpp:mam:0"** complete="true">

        <set xmlns="http://jabber.org/protocol/rsm">

             <first index="0">231</first>

             <last>238</last>

             <count>8</count>

        </set>

   </fin>

Running the response through a XML validator revealed that the tag contains 2 different namespaces: “jabber:client” as well as “urn:xmpp:mam:0”.

I would appreciate if someone could look into this, as I am currently blocked here.

I have the same issue, after upgrading from version 3.10.2 to 3.10.3, I get a null resulv with invalid XML response. I’m using monitoring plugin 1.4.7 before and after upgrade. So I downgraded again to version 3.10.2 and message archiving works fine otherwise I need to upgrade openfire.

Thanks for reporting this issue. I’ve added it to our issue tracker as [OF-1087] Monitoring plugin gives invalid responses - Jive Software Open Source

On a side-note: the ‘advanced editor’ of this website allows for syntax highlighting: that save you from a lot of painstaking formatting.

Thanks

Thank you Guus and good to know that there’s an advanced editor ;-).

I’m confident that I’ve addressed the issue. The corresponding code changes are in this pull request: OF-1087: Default namespace handling in BOSH. by guusdk · Pull Request #539 · igniterealtime/Openfire · GitHub

Although this is a bug introduced in Openfire, we can work around it by applying a small change (that should be a non-functional change) to the monitoring plugin. This change is part of the PR above.

My goal is to release a fix for this problem in the next release of Openfire, but also release a modified version of the Monitoring plugin that can be used with Openfire 4.0.0 and 4.0.1. Only one of both solutions is required to address the problem.

The impatient can rebuild a new Monitoring plugin based on the PR and deploy the change locally.

Hi Guus,

thanks very much for your quick response, I guess I’ll just rebuild the plugin for the time being.

By the way I also noted another potential issue when querying a message archive. The XEP-0313 spec states:

To ensure that the client knows when the results are complete, the server MUST send the result after the last message retrieved from the archive. The client can optionally include a ‘queryid’ attribute in their query, which allows the client to match results to their initiating query.

However, it seems as if the iq result is sent before all the archived messages. Can you validate this or should I create a separate thread for this issue?

A new version of the monitoring plugin (1.5.1) is now available for download at Ignite Realtime: Openfire Plugins

As for your question regarding message ordering: I’m not familiar with the XEP-0313 implementation details, but I guess it couldn’t hurt to send the IQ result only after the messages have been transmitted. The existing code is synchronous anyway. I’ve raised [OF-1089] XEP-0313: send IQ result only after messages - Jive Software Open Source for this.

That was fast, thanks a lot!

Works perfect. Thanks Guus for the quick response and thanks Sven for posting the issue.

Hi,

Sorry to bother you, but I’m running Openfire 4.0.2 with Monitoring Service 1.51, and I have, I think, the same issue : when retrieving the archive, the messages are not parsed, leaving me with ‘Forwarded’ and ‘Delayed’ objects only. The namespace of <messages …> appears empty, which I was told is surely the issue : Unable to get messages from history · Issue #139 · otalk/stanza.io · GitHub

Your fix did not correct this properly? Or is this a different issue that needs its own thread?

Thanks in advance!

Your issue is related, indeed. As the original issue has already been closed, I’ve created a new one in our issue tracker: [OF-1132] Monitoring plugin does not add namespace - IgniteRealtime JIRA