AvatarManager.publishAvatar() fails with <item-not-found/> StanzaException

Issue #28 closed
Markus KARG created an issue

I'm using master 2a3c456 to send an avatar:

try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
    ImageIO.write(SwingFXUtils.fromFXImage(new Image(Paths.get("My Pictures", "My Portrait.jpg").toUri().toString()), null), "png", os);
    final byte[] bytes = os.toByteArray();
    final AvatarManager avatarManager = session.getManager(AvatarManager.class);
    avatarManager.setEnabled(true);
    avatarManager.publishAvatar(bytes);
} catch (final Throwable t) {
    t.printStackTrace();
}

which results in the following output:

OUT: <iq from="mkarg2@jabber.de/eclipse" id="disco" to="mkarg2@jabber.de" type="result"><query xmlns="http://jabber.org/protocol/disco#info"><identity category="client" type="pc"></identity><feature var="http://jabber.org/protocol/bytestreams"></feature><feature var="http://jabber.org/protocol/caps"></feature><feature var="http://jabber.org/protocol/chatstates"></feature><feature var="http://jabber.org/protocol/disco#info"></feature><feature var="http://jabber.org/protocol/disco#items"></feature><feature var="http://jabber.org/protocol/ibb"></feature><feature var="http://jabber.org/protocol/rsm"></feature><feature var="http://jabber.org/protocol/si"></feature><feature var="http://jabber.org/protocol/si/profile/file-transfer"></feature><feature var="jabber:iq:last"></feature><feature var="jabber:iq:oob"></feature><feature var="jabber:iq:version"></feature><feature var="jabber:x:oob"></feature><feature var="jid\20escaping"></feature><feature var="urn:xmpp:avatar:metadata"></feature><feature var="urn:xmpp:avatar:metadata+notify"></feature><feature var="urn:xmpp:hash-function-text-names:md5"></feature><feature var="urn:xmpp:hash-function-text-names:sha-1"></feature><feature var="urn:xmpp:hash-function-text-names:sha-224"></feature><feature var="urn:xmpp:hash-function-text-names:sha-256"></feature><feature var="urn:xmpp:hash-function-text-names:sha-384"></feature><feature var="urn:xmpp:hash-function-text-names:sha-512"></feature><feature var="urn:xmpp:hashes:1"></feature><feature var="urn:xmpp:ping"></feature><feature var="urn:xmpp:time"></feature><feature var="vcard-temp"></feature></query></iq>
IN : <presence from="mkarg2@jabber.de/eclipse"><priority>10</priority><x xmlns="vcard-temp:x:update"></x><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://xmpp.rocks" ver="YhsriNHd0WY9WvfFv1FIeNd6Elw="></c></presence>
IN : <iq id="7ef56b90-3512-40b0-9934-54c448d06fc5" to="mkarg2@jabber.de/eclipse" type="error"><error type="cancel"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></item-not-found></error></iq>
IN : <iq id="d0bf3e5d-0b4a-4950-b40f-7a012d3dd2ab" to="mkarg2@jabber.de/eclipse" type="error"><error type="cancel"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></item-not-found></error></iq>
OUT: <presence><priority>10</priority><x xmlns="vcard-temp:x:update"><photo></photo></x><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://xmpp.rocks" ver="YhsriNHd0WY9WvfFv1FIeNd6Elw="></c></presence>
rocks.xmpp.core.stanza.StanzaException: <item-not-found/>  -  (type 'cancel': do not retry (the error cannot be remedied))
    at rocks.xmpp.core.session.XmppSession.query(XmppSession.java:540)
    at rocks.xmpp.core.session.XmppSession.query(XmppSession.java:483)
    at rocks.xmpp.extensions.vcard.temp.VCardManager.getVCard(VCardManager.java:62)
    at rocks.xmpp.extensions.avatar.AvatarManager.publishToVCard(AvatarManager.java:500)
    at rocks.xmpp.extensions.avatar.AvatarManager.publishAvatar(AvatarManager.java:482)
    at application.chat.XmppChat$1.call(XmppChat.java:182)
    at application.chat.XmppChat$1.call(XmppChat.java:1)
    at javafx.concurrent.Task$TaskCallable.call(Task.java:1423)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.lang.Thread.run(Thread.java:745)
OUT: </stream:stream>
IN : <presence from="mkarg2@jabber.de/eclipse"><priority>10</priority><x xmlns="vcard-temp:x:update"><photo></photo></x><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://xmpp.rocks" ver="YhsriNHd0WY9WvfFv1FIeNd6Elw="></c></presence>

Comments (4)

  1. Christian Schudt repo owner

    Add better fallback logic to avatar publishing.

    Only throw an exception if all publishing methods fail. If only one fails log only. Also create a new VCard, if none exist yet.

    Fixes Issue #28.

    → <<cset 77db631b0578>>

  2. Christian Schudt repo owner

    Couldn't reproduce, but added more defensive logic for this. Please see if it's better now.

  3. Log in to comment