4 Replies Latest reply on Jul 14, 2017 10:59 PM by cmeng

    Smack XEP-0084 - publishing avatar data to node with exception failing XEP-60 5.3 requirements

    cmeng

      aTalk just implemented XEP-0084: User Avatar; and is working with PEPListener being correctly triggered on avatar metaData event and a successful retrieving of its avatar Data. However when aTalk tries to publishAvatarData(), it fails with an exception as indicated in the attached log on executing the statement mPepManager.publish(item, node);  i.e. failing  XEP-60 5.3 requirements.

       

      As per XEP-0060 section 5.3. it seems smack did not set the 'to' attribute with the right entity, which may have led to incorrect reply from the server.

       

      5.3 Discover Node Information

      Example 13. Entity queries collection node for information

      A pubsub service MUST allow entities to query individual nodes for the information associated with that node. The Service Discovery protocol MUST be used to discover this information. The "disco#info" result MUST include an identity with a category of "pubsub" and a type of either "leaf" or "collection".

      Note: If a node has an identity type of "leaf", then it MUST NOT contain other nodes or collections (only items); if a node has an identity type of "collection", then it MUST NOT contain items (only other nodes or collections).

      Example 13. Entity queries collection node for information

      <iq type='get'
         
      from='francisco@denmark.lit/barracks'
         
      to='pubsub.shakespeare.lit'
         
      id='info2'>
       
      <query xmlns='http://jabber.org/protocol/disco#info'
              
      node='blogs'/>
      </iq>

      Example 14. Service responds with identity of pubsub/collection

      <iq type='result'
         
      from='pubsub.shakespeare.lit'
         
      to='francisco@denmark.lit/barracks'
         
      id='meta1'>
       
      <query xmlns='http://jabber.org/protocol/disco#info'
              
      node='blogs'>
         
      <identity category='pubsub' type='collection'/>
       
      </query>
      </iq>

       

      //============ atalk publishAvatarData() method ================

      /**
      * Publish an avatar data.
      *
      * @param id
      * the id of the avatar data
      * @param data
      * the data of the avatar
      */
      private void publishAvatarData(String id, byte[] data)
      {
         AvatarData avatar = new AvatarData(data);
         PayloadItem<AvatarData> item = new PayloadItem<>(id, avatar);
         String node = AvatarData.NAMESPACE;

         try {
         mPepManager.publish(item, node);
         }
         catch (SmackException.NotConnectedException | SmackException.NoResponseException
         | InterruptedException | XMPPException.XMPPErrorException e) {
         LOGGER.log(Level.WARNING, "Error while publishing avatar data: " + e.getMessage());
         }
      }

       

      ============ aTalk log when attempts to publish userAvatar ===================

      07-14 16:57:37.922 D/SMACK: SENT (1): <iq to='test@atalk.org' id='qg40p-242' type='get'><query xmlns='http://jabber.org/protocol/disco#info' node='urn:xmpp:avatar:data'></query></iq>

      07-14 16:57:37.932 D/SMACK: RECV (1): <iq xml:lang='en' to='test@atalk.org/atalk' from='test@atalk.org' type='result' id='qg40p-242'><query node='urn:xmpp:avatar:data' xmlns='http://jabber.org/protocol/disco#info'><identity type='registered' category='account'/></query></iq>

      07-14 16:57:37.982 E/αTalk: [1] util.UtilActivator.uncaughtException().95 An uncaught exception occurred in thread=Thread[main,5,main] and message was: PubSub service 'test@atalk.org' returned disco info result for node 'urn:xmpp:avatar:data', but it did not contain an Identity of type 'leaf' or 'collection' (and category 'pubsub'), which is not allowed according to XEP-60 5.3.

                                  org.jivesoftware.smackx.pubsub.PubSubAssertionError$DiscoInfoNodeAssertionError : PubSub service 'test@atalk.org' returned disco info result for node 'urn:xmpp:avatar:data', but it did not contain an Identity of type 'leaf' or 'collection' (and category 'pubsub'), which is not allowed according to XEP-60 5.3.

                                      at org.jivesoftware.smackx.pubsub.PubSubManager.getNode(PubSubManager.java:255)

                                      at org.jivesoftware.smackx.pep.PEPManager.publish(PEPManager.java:145)

                                      at org.jivesoftware.smackx.avatar.useravatar.UserAvatarManager.publishAvatarData(U serAvatarManager.java:187)

                                      at org.jivesoftware.smackx.avatar.useravatar.UserAvatarManager.publishAvatarData(U serAvatarManager.java:167)

                                      at org.jivesoftware.smackx.avatar.useravatar.UserAvatarManager.publishBitmap(UserA vatarManager.java:279)

                                      at org.jivesoftware.smackx.avatar.useravatar.UserAvatarManager.publishAvatar(UserA vatarManager.java:251)

                                      at org.atalk.android.gui.account.AccountInfoPresenceActivity.onActivityResult(Acco untInfoPresenceActivity.java:1214)

                                      at android.app.Activity.dispatchActivityResult(Activity.java:6548)

                                      at android.app.ActivityThread.deliverResults(ActivityThread.java:4050)

                                      at android.app.ActivityThread.handleSendResult(ActivityThread.java:4097)

                                      at android.app.ActivityThread.access$1400(ActivityThread.java:177)

                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1497)

                                      at android.os.Handler.dispatchMessage(Handler.java:102)

                                      at android.os.Looper.loop(Looper.java:145)

                                      at android.app.ActivityThread.main(ActivityThread.java:5938)

                                      at java.lang.reflect.Method.invoke(Native Method)

                                      at java.lang.reflect.Method.invoke(Method.java:372)

                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389 )

                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)

      07-14 16:57:37.982 E/αTalk: [1] org.atalk.android.plugin.errorhandler.ExceptionHandler.uncaughtException().78 uncaughtException occurred, killing the process...

                                  org.jivesoftware.smackx.pubsub.PubSubAssertionError$DiscoInfoNodeAssertionError : PubSub service 'test@atalk.org' returned disco info result for node 'urn:xmpp:avatar:data', but it did not contain an Identity of type 'leaf' or 'collection' (and category 'pubsub'), which is not allowed according to XEP-60 5.3.

                                      at org.jivesoftware.smackx.pubsub.PubSubManager.getNode(PubSubManager.java:255)

                                      at org.jivesoftware.smackx.pep.PEPManager.publish(PEPManager.java:145)

                                      at org.jivesoftware.smackx.avatar.useravatar.UserAvatarManager.publishAvatarData(U serAvatarManager.java:187)

                                      at org.jivesoftware.smackx.avatar.useravatar.UserAvatarManager.publishAvatarData(U serAvatarManager.java:167)

                                      at org.jivesoftware.smackx.avatar.useravatar.UserAvatarManager.publishBitmap(UserA vatarManager.java:279)

                                      at org.jivesoftware.smackx.avatar.useravatar.UserAvatarManager.publishAvatar(UserA vatarManager.java:251)

                                      at org.atalk.android.gui.account.AccountInfoPresenceActivity.onActivityResult(Acco untInfoPresenceActivity.java:1214)

                                      at android.app.Activity.dispatchActivityResult(Activity.java:6548)

                                      at android.app.ActivityThread.deliverResults(ActivityThread.java:4050)

                                      at android.app.ActivityThread.handleSendResult(ActivityThread.java:4097)

                                      at android.app.ActivityThread.access$1400(ActivityThread.java:177)

                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1497)

                                      at android.os.Handler.dispatchMessage(Handler.java:102)

                                      at android.os.Looper.loop(Looper.java:145)

                                      at android.app.ActivityThread.main(ActivityThread.java:5938)

                                      at java.lang.reflect.Method.invoke(Native Method)

                                      at java.lang.reflect.Method.invoke(Method.java:372)

                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389 )

                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)