问题
I am using monitoring plugin 1.6.0 with openfire 4.2.0.
Following is the screenshot of archive settings on openfire admin Console.
also following is the screenshot of plugins I am using with this.
My Issue
as you can see the plugin is installed. but when I am trying to fetch chat history with following code : I am getting service unavailable response.
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)
}
OutPut Log :-
<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>
Response :--
<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:
openfire do not support urn:xmpp:mam:2
you have to use urn:xmpp:mam:1
instead.
you have to change it in XMPPMessageArchiveManagemnt class.
just go to XMPPMessageArchiveManagement class .in line of 20 it said
/** 'urn:xmpp:mam:2' */ extern NSString *const XMLNS_XMPP_MAM;
.
just hold command and click on XMLNS_XMPP_MAM after that change urn:xmpp:mam:2
to urn:xmpp:mam:1
来源:https://stackoverflow.com/questions/51237997/service-unavailable-error-in-openfire-message-archive-management