openfire邮件档案管理中的服务不可用错误

时间:2018-07-09 03:50:36

标签: ios openfire xmppframework

我正在使用带有Openfire 4.2.0的监控插件1.6.0。

以下是openfire管理控制台上的存档设置的屏幕截图。

enter image description here

以下也是我与此配合使用的插件的屏幕截图。 enter image description here

我的问题

如您所见,插件已安装。 但是,当我尝试使用以下代码获取聊天记录时:我得到的服务不可用响应。

func fetchChatHistoryFromServer(completionHandler completion: @escaping FetchChatHistoryCompletionHandler) {

    let iq = DDXMLElement(name: "iq")
    iq.addAttribute(withName: "type", stringValue: "set")
    iq.addAttribute(withName: "id", stringValue: UserManager.shared.activeUser.jid)

    let query = DDXMLElement(name: "query")
    query.setXmlns("urn:xmpp:mam:2")
    query.addAttribute(withName: "queryid", stringValue: XMPPManager.shared.xmppStream.generateUUID)

    let x = DDXMLElement(name: "x")
    x.setXmlns("jabber:x:data")
    x.addAttribute(withName: "type", stringValue: "submit")


    let field = DDXMLElement(name: "field")
    field.addAttribute(withName: "var", stringValue: "FORM_TYPE")
    field.addAttribute(withName: "type", stringValue: "hidden")
    let fieldValue = DDXMLElement(name: "value", stringValue: "urn:xmpp:mam:2")
    field.addChild(fieldValue)
    x.addChild(field)
    query.addChild(x)
    iq.addChild(query)
    //let xmppResultSet = XMPPResultSet(max: 2000)
    Logger.log(iq)
    didFetchChatHistoryCompletionBlock = completion
    xmppMessageArchivingManagement?.retrieveMessageArchive(withFields: [iq], with: nil)
}

输出日志:-

<iq type="set" id="dev60@dev.myapp.com">
    <query xmlns="urn:xmpp:mam:2" queryid="20B07616-12BC-41BB-9DE6-F0F6A74951A5">
        <x xmlns="jabber:x:data" type="submit">
            <field var="FORM_TYPE" type="hidden">
                <value>urn:xmpp:mam:2</value>
            </field>
        </x>
     </query>
</iq>

响应:-

<iq xmlns="jabber:client" type="error" id="7BED0303-46E3-40D4-BE47-543BB7810F66" to="dev60@dev.myapp.com/a3lb3jaw9g">
<query xmlns="urn:xmpp:mam:2" queryid="80D6D753-B2BF-4626-84B5-C216D4B94996">
    <x xmlns="jabber:x:data" type="submit">
        <field var="FORM_TYPE" type="hidden">
        <value>urn:xmpp:mam:2</value>
        </field>
        <iq type="set" id="dev60@dev.myapp.com">
            <query xmlns="urn:xmpp:mam:2" queryid="20B07616-12BC-41BB-9DE6-F0F6A74951A5">
                <x xmlns="jabber:x:data" type="submit">
                    <field var="FORM_TYPE" type="hidden">
                        <value>urn:xmpp:mam:2</value>
                    </field>
                </x>
            </query>
        </iq>
    </x>
</query>
<error code="503" type="cancel">
    <service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></service-unavailable>
</error>

1 个答案:

答案 0 :(得分:4)

openfire不支持urn:xmpp:mam:2,您必须使用urn:xmpp:mam:1。 您必须在XMPPMessageArchiveManagemnt类中进行更改。 只需转到XMPPMessageArchiveManagement类。在第20行中说 /** 'urn:xmpp:mam:2' */ extern NSString *const XMLNS_XMPP_MAM;。 只需按住命令并单击XMLNS_XMPP_MAM,然后将urn:xmpp:mam:2更改为urn:xmpp:mam:1