Can not receive cuntom IQ packet in smack4.2.0-beta2

I can receive custom IQ packet using aSmack which might be developed according to smack 3.4.0.

Now I update the smack library to 4.2.0-beta2, and can’t receive.

NotificationIQProvider is like following:

public class NotificationIQProvider extends IQProvider {

public NotificationIQProvider() {


public NotificationIQ parse(XmlPullParser parser, int arg1)

throws XmlPullParserException, IOException, SmackException {

// TODO Auto-generated method stub;

 NotificationIQ notification = new NotificationIQ();
 for (boolean done = false; !done;) {



NotificationIQ is like following:

public class NotificationIQ extends IQ {

public static final String ELEMENT = “notifications”;
public static final String NAMESPACE = “androidrs:iq:notifications”;

public NotificationIQ() {


protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder iqChildElementXmlStringBuilder) {

// TODO Auto-generated method stub
return null;


And I register my IQ provider:

new NotificationIQProvider());

You need o register an IQ request handler: smack/XMPPConnection.html#registerIQRequestHandler-org.jivesoftware.smack.iqrequ est.IQRequestHandler

Sorry, I still couldn’t receive.

I implement a handler:

public class CustomIQRequestHandler extends AbstractIqRequestHandler {

public CustomIQRequestHandler(String element, String namespace, IQ.Type type, Mode mode) {

super(element, namespace, type, mode);

public IQ handleIQRequest(IQ iq) {

NotificationIQ notificationIQ = (NotificationIQ) iq;
return IQ.createResultIQ(notificationIQ);


And, after connecting successfully, I register the handler:

conn.registerIQRequestHandler(new CustomIQRequestHandler(


Besides, the client which sends custom IQ packet are still using aSmack.

Is it related to the problem?

Now I set a breakpoint in the function

protected void invokePacketCollectorsAndNotifyRecvListeners(final Stanza packet)

if(packet instanceof IQ) {

final IQ listenersToNotify = (IQ)packet;
org.jivesoftware.smack.packet.IQ.Type type = listenersToNotify.getType(); (breakpoint)

When ping packets arrive, it can reach the breakpoint.

But when I send custom IQ packet, it can’t.

I find the reason.

I haven’t set resource in smack 4.2.0-beta2.


While It is automatically set by library in aSmack.

Before setting resource, the “to” look like this:

After setting resource, the “to” look like this:

Thank you all the same!