简体   繁体   中英

Get XMPP Chat History OpenFire

I am trying to implement a chat application using XMPPFramework in iOS, using OpenFire server. My chat is working fine, I am trying to retrieve chat history from server. Ofcourse I have enabled Message Archiving on Server. This is the Request I am sending

<iq type="get">
   <retrieve xmlns="urn:xmpp:archive" with="dev_user80@mydomain">
       <set xmlns="http://jabber.org/protocol/rsm">
           <max>100</max>
       </set>
   </retrieve>
</iq>

This is the response I am getting.

<iq xmlns="jabber:client" type="error" to="dev_user103@mydomain/6i0qoo9tek">
    <retrieve xmlns="urn:xmpp:archive" with="dev_user80@mydomain">
        <set xmlns="http://jabber.org/protocol/rsm">
            <max>100</max>
        </set>
    </retrieve>
    <error code="503" type="cancel">
        <service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">
        </service-unavailable>
    </error>
</iq>

I have gone through all the solutions I could find on the internet but could not find a satisfying solution

change urn:xmpp:archive to urn:xmpp:archive:auto

I had the same issue and determined this by running a discovery request: http://xmpp.org/extensions/xep-0136.html#disco

I sent this IQ:

<iq from='user@mydomain.com'
    id='disco1' 
    to='mydomain.com'
    type='get'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>

My Openfire server with the Monitoring plugin enabled returned this result:

<iq xmlns="jabber:client" type="result" id="disco1" from="mydomain.com" to="user@mydomain.com/resource">
   <query xmlns="http://jabber.org/protocol/disco#info">
      <identity category="server" name="Openfire Server" type="im" />
      <identity category="pubsub" type="pep" />
      <feature var="http://jabber.org/protocol/pubsub#retrieve-default" />
      <feature var="http://jabber.org/protocol/pubsub#purge-nodes" />
      <feature var="vcard-temp" />
      <feature var="http://jabber.org/protocol/pubsub#subscribe" />
      <feature var="http://jabber.org/protocol/pubsub#subscription-options" />
      <feature var="http://jabber.org/protocol/pubsub#create-nodes" />
      <feature var="http://jabber.org/protocol/pubsub#outcast-affiliation" />
      <feature var="msgoffline" />
      <feature var="http://jabber.org/protocol/pubsub#get-pending" />
      <feature var="http://jabber.org/protocol/pubsub#multi-subscribe" />
      <feature var="http://jabber.org/protocol/pubsub#presence-notifications" />
      <feature var="urn:xmpp:ping" />
      <feature var="jabber:iq:register" />
      <feature var="http://jabber.org/protocol/pubsub#delete-nodes" />
      <feature var="http://jabber.org/protocol/pubsub#config-node" />
      <feature var="urn:xmpp:archive:manage" />
      <feature var="http://jabber.org/protocol/pubsub#retrieve-items" />
      <feature var="http://jabber.org/protocol/pubsub#auto-create" />
      <feature var="http://jabber.org/protocol/disco#items" />
      <feature var="http://jabber.org/protocol/pubsub#item-ids" />
      <feature var="http://jabber.org/protocol/pubsub#meta-data" />
      <feature var="urn:xmpp:mam:0" />
      <feature var="jabber:iq:roster" />
      <feature var="http://jabber.org/protocol/pubsub#instant-nodes" />
      <feature var="http://jabber.org/protocol/pubsub#modify-affiliations" />
      <feature var="http://jabber.org/protocol/pubsub#persistent-items" />
      <feature var="http://jabber.org/protocol/pubsub#create-and-configure" />
      <feature var="http://jabber.org/protocol/pubsub" />
      <feature var="http://jabber.org/protocol/pubsub#publisher-affiliation" />
      <feature var="http://jabber.org/protocol/pubsub#access-open" />
      <feature var="http://jabber.org/protocol/pubsub#retrieve-affiliations" />
      <feature var="jabber:iq:version" />
      <feature var="http://jabber.org/protocol/pubsub#retract-items" />
      <feature var="urn:xmpp:time" />
      <feature var="http://jabber.org/protocol/pubsub#manage-subscriptions" />
      <feature var="jabber:iq:privacy" />
      <feature var="jabber:iq:last" />
      <feature var="http://jabber.org/protocol/commands" />
      <feature var="http://jabber.org/protocol/offline" />
      <feature var="urn:xmpp:carbons:2" />
      <feature var="http://jabber.org/protocol/address" />
      <feature var="http://jabber.org/protocol/pubsub#publish" />
      <feature var="http://jabber.org/protocol/pubsub#collections" />
      <feature var="http://jabber.org/protocol/pubsub#retrieve-subscriptions" />
      <feature var="urn:xmpp:archive:auto" />
      <feature var="http://jabber.org/protocol/disco#info" />
      <feature var="jabber:iq:private" />
      <feature var="http://jabber.org/protocol/rsm" />
   </query>
</iq>

You can see that Automatic Archiving ( urn:xmpp:archive:auto ) and Archive Management ( urn:xmpp:archive:manage ) are supported, but Manual Archiving ( urn:xmpp:archive:manual ) and Archiving Preferences ( urn:xmpp:archive:pref ) are not.

XEP-0313 is also supported (listed as urn:xmpp:mam:0 ) and can retrieve archived messages: http://xmpp.org/extensions/xep-0313.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM