I am developing a chat application using Smack api and I got stuck at receiving presence packets.
Tested with Smack 3.2.2 and 3.3.0.
These problems involve only using Openfire server 3.8.1.
First:I am sending the presence packet from Spark and receiving it with success
second I am updating and sending presence packet from Spark client to my own:
<presence id="b8nyI-95">
<status>Free to chat</status>
<priority>1</priority>
<show>chat</show>
<x xmlns="vcard-temp:x:update">
<photo>d37b60faea717f9f7ca08bef1504d2de68a789eb</photo>
</x>
<x xmlns="jabber:x:avatar">
<hash>d37b60faea717f9f7ca08bef1504d2de68a789eb</hash>
</x>
</presence>
and receiving back in Spark debug :
<presence id="b8nyI-95" to="test2@localhost/Spark 2.6.3" from="test3" type="error">
<error code="404" type="CANCEL">
<remote-server-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
</presence>
no packet is received in my own client. This appears only when I try to update my presence in Spark.
testing with another xmpp server : I think it's ejabberd
Sending presence from Spark :
<presence id="B0ANe-55">
<status>Free to chat</status>
<priority>1</priority>
<show>chat</show>
</presence>
*Receiving it into my chat app *
<presence from='[email protected]/Spark 2.6.3' to='[email protected]/Smack' id='B0ANe-55'>
<status>Free to chat</status>
<priority>1</priority>
<show>chat</show>
</presence>
Both rosters have subscription set to :both
-with Openfire I am able to : connect, receive roster list (it gets the presence that is at the moment of initialization), send and receive messages, send files .
---can't do : update roster presence: tried with RosterListener and reloading the roster into my list
I've added a RosterListener
Roster roster = Client.getClient().connection.getRoster();
roster.addRosterListener(new RosterListener() {
@Override
public void entriesAdded(Collection<String> addresses) {}
@Override
public void entriesDeleted(Collection<String> addresses) {}
@Override
public void entriesUpdated(Collection<String> addresses) {}
@Override
public void presenceChanged(Presence presence) {
System.out.println("Presence changed: " + presence.getFrom() + " " + presence);
}
});
->Doesn't work when updating the presence of rosters with Openfire // with the other server everything is fine.
->also added (don't know if it helps or not with my problem):
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
if (sdm == null){
sdm = new ServiceDiscoveryManager(connection);}
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("http://jabber.org/protocol/disco#item");
sdm.addFeature("http://jabber.org/protocol/caps");
JingleManager.setJingleServiceEnabled();
ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new VCardProvider());
Already went through Google and StackOverflow.
If anyone can help I would appreciate.