openfire 消息存档管理中的服务不可用错误

service unavailable error in openfire message archive management

我在 openfire 4.2.0 上使用监控插件 1.6.0。

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

下面还有我使用的插件截图。

我的问题

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

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>

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