<iq type="error" to="DOMAINNAME" id="969-9310"><query xmlns="jabber:iq:version"/><error type="cancel" code="501"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
I am beginner in XMPP. I want to implement chat application with OpenFire server. I have integrated "pod 'XMPPFramework/Swift'" Pod... I am able to make the proper connection with the server, but when I want to send any message to another Jabberid, I am receiving an error
SEND: <iq type="error" to="DOMAINMANE" id="348-5581"><query xmlns="jabber:iq:version"/><error type="cancel" code="501"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
Here is the code,which I tried `extension AppDelegate{ private func setupStream() { //xmppRoster = XMPPRoster(rosterStorage: xmppRosterStorage) xmppRoster.activate(xmppStream) self.xmppStream.addDelegate(self, delegateQueue: DispatchQueue.main) self.xmppRoster.addDelegate(self, delegateQueue: DispatchQueue.main)
}
func connect() -> Bool {
if !xmppStream.isConnected {
let jabberID = GlobleConstants.senderJID
if !xmppStream.isDisconnected {
return true
}
xmppStream.myJID = XMPPJID(string: jabberID)
do {
try xmppStream.connect(withTimeout: XMPPStreamTimeoutNone)
self.xmppMessageDeliveryRecipts.autoSendMessageDeliveryReceipts = true
self.xmppMessageDeliveryRecipts.autoSendMessageDeliveryRequests = true
self.xmppMessageDeliveryRecipts.activate(self.xmppStream)
print("Connection success")
return true
} catch {
print("Something went wrong!")
return false
}
} else {
return true
}
}
func disconnect() {
goOffline()
xmppStream.disconnect()
}
private func goOnline() {
let presence = XMPPPresence()
let domain = xmppStream.myJID?.domain
if domain == GlobleConstants.XMPPHOSTNAME || domain == "gmail.com" || domain ==
"gtalk.com" ||
domain == "talk.google.com" {
let priority = DDXMLElement.element(withName: "priority", stringValue: "24") as!
DDXMLElement
presence.addChild(priority)
}
xmppStream.send(presence)
}
private func goOffline() {
let presence = XMPPPresence(type: "unavailable")
xmppStream.send(presence)
}
}
extension AppDelegate : XMPPStreamDelegate{
func xmppStreamDidConnect(_ sender: XMPPStream) {
do {
try xmppStream.authenticate(withPassword: GlobleConstants.sPassword)
} catch {
print("Could not authenticate")
}
}
func xmppStreamDidAuthenticate(_ sender: XMPPStream) {
goOnline()
}
func xmppStream(_ sender: XMPPStream, didReceive iq: XMPPIQ) -> Bool { print("Did receive IQ") return false }
func xmppStream(_ sender: XMPPStream, didReceive message: XMPPMessage) { print("Did send message (message)") } func xmppStream(_ sender: XMPPStream, didReceive presence: XMPPPresence) { print("IN APPDELEGATE -----> ", presence) let presenceType = presence.presenceType?.rawValue let myUsername = sender.myJID?.user let presenceFromUser = presence.from?.user print("MY USERNAME ",myUsername) print("OTHER USER NAME ",presenceFromUser) print("PRESNET ",presenceType) //HERE ALSO NOT GETTING ANOTHER ONLINE USER, SO THAT I CAN ADD INTO ONLINE BUDDIES LIST /if presenceFromUser != myUsername { print("Did receive presence from (presenceFromUser)") if presenceType == "available" { delegate.buddyWentOnline(name: "(presenceFromUser)@(GlobleConstants.XMPPHOSTNAME)") } else if presenceType == "unavailable" { delegate.buddyWentOffline(name: "(presenceFromUser)@(GlobleConstants.XMPPHOSTNAME)") } }/ }
} extension AppDelegate : XMPPRosterDelegate{ func xmppRoster(_ sender: XMPPRoster, didReceiveRosterItem item: DDXMLElement) { print("Did receive Roster item") } }`
And now inside of the controller, I am trying to fetch online buddies by
func setupUI(){ appDelegate.delegate = self if appDelegate.connect() { self.title = appDelegate.xmppStream.myJID?.user appDelegate.xmppRoster.fetch() } self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") }
Also , when I try to send a sample message to the receiver , I am facing the same error. Here is code to send the sample message.
func sendSimpleMessage(sender: XMPPStream){ let body = DDXMLElement.element(withName: "body") as! DDXMLElement let message = DDXMLElement.element(withName: "message") as! DDXMLElement message.addAttribute(withName: "type", stringValue: "chat") message.addAttribute(withName: "to", stringValue: GlobleConstants.receiverJID) message.addChild(body) sender.send(message) }
Anyone having solution for the same?