Problem parsing PEP events in Smack 4.1.3

Hiya Flow,

Having problems parsing a PEP event with Smack 4.1.3 in android. Wondering if you could suggest where I could be going wrong? Log is:

08-03 19:13:48.577 17198-18129/com.test D/SMACK﹕ RECV (0): xxxxxxxx

08-03 19:13:48.667 17198-18172/com.test E/AbstractXMPPConnection﹕ Exception in packet listener

** java.lang.ClassCastException: org.jivesoftware.smackx.pubsub.EventElement cannot be cast to org.jivesoftware.smackx.pep.packet.PEPEvent**

** at org.jivesoftware.smackx.pep.PEPManager$1.processPacket(PEPManager.java:140)**

** at org.jivesoftware.smack.AbstractXMPPConnection$4.run(AbstractXMPPConnection.java :1131)**

** at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)**

** at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)**

** at java.lang.Thread.run(Thread.java:841)**

Thanks Flow,

Dave

Code pls

Sorry Flow, here’s what I think is pertinent:

public static final String PEP_PROFILE_UPDATE_NAMESPACE = “urn:xmpp:profupd:0”;

/--------------------------------------------------------------/

//Personal Eventing Protocol xep-0163
pepManager=new PEPManager(conn);

pepManager.addPEPListener(this);

//Get an instance of EntityCapsManager
ServiceDiscoveryManager discoveryManager=ServiceDiscoveryManager.getInstanceFor(conn);

//Subscribe to pep broadcasts by advertising our support PEP (XEP-0163)
discoveryManager.addFeature(VCardPEPItem.PEP_PROFILE_UPDATE_NAMESPACE);

discoveryManager.addFeature(VCardPEPItem.PEP_PROFILE_UPDATE_NAMESPACE + “+notify”);

/---------------------------------------------------------------/

public class VCardPEPItem extends PEPItem {

public static final String PEP_PROFILE_UPDATE_NAMESPACE = “urn:xmpp:profupd:0”;

public VCardPEPItem(){

super(StringUtils.randomString(7));

}

@Override
public String getNode() {

return PEP_PROFILE_UPDATE_NAMESPACE;

}

@Override
public String getItemDetailsXML() {

return “”;

}

}

That is because of SMACK-416.

OK, thanks Flow. It seems the current implementation of PEP is pretty broken, is it likely to be working in the next release (4.1.4)? I need it working for my project, and tried re-jaring the extensions jar without the pubsub module to overcome the conflict, but this seemed to cause more problems then it solved (couldn’t find the classes when initializing the extensions). Any ideas how I could most easily get it working again?

Cheers

Ignore everything in the o.j.smackx.pep package and use Smack’s PubSub API. After all PEP is just PubSub using the user’s bare JID as PubSub service.

Thanks Flow.

As far as I can tell, the existing PubSub extension is insufficient for use as a PEP extension. ItemPublishEvent, when passed as a parameter via the ItemEventListener, does not pass the “from” field of the stanza, meaning we cannot tell from which of our contacts the event came from. This is critical - in my case, the payload of the event is less important than knowing from whom the event came from. There seems to be no quick fix for this.

Also, the documentation here for the PubSub extension is wrong and out of date. In general, the documentation is pretty terse and out of date - it would be nice if this could be hosted wiki-style so contributors could easily tidy it up and add our code samples for others.

Any thoughts?

thanks

dave

You can always use a stanza listener to listen for PEP events. See the upcoming changes for PEP in Smack 4.2: Refactor PEP to use PubSub API. · Flowdalic/Smack@33e5c37 · GitHub

Feedback welcomed.

Also, the documentation here for the PubSub extension is wrong and out of date. In general, the documentation is pretty terse and out of date - it would be nice if this could be hosted wiki-style so contributors could easily tidy it up and add our code samples for others.

You are free to

  • Use Smack’s github wiki
  • Post the documentation errors in the forums
  • even better: Issue a PR fixing the documentation errors

Thanks Flow for your help.

I’ve observed that in the PubSub extension, when calling pubSubManager.getNode on a node that hasn’t been created yet, it throws a Throwable (an AssertionError from memory), which jumps past all my exception handlers and crashes the app.

I wonder if this should either be throwing an XMPPException, or possibly just returning null, than this rather heavy-handed death-knell??

By the way, what is a PR?

Thanks again,

dave

If it’s the AssertionError I think it is, then Smack is right to throw it imho. We could introduce an unchecked XmppSpecificationViolationException instead, but this wouldn’t fix the underlying issue: The PubSub component is violating the spec. Go fix it. Until it is fixed, catch the AssertionError and handle it.

PR: A Github pull request.

I just spend some useless time with getting the PEPManager to work. Plz remove the code or mark as deprecated or something so stupid people (like me) don’t get confused with it.