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() {

}

@Override
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() {

super(ELEMENT, NAMESPACE);
}

@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder iqChildElementXmlStringBuilder) {

// TODO Auto-generated method stub
return null;
}

}

And I register my IQ provider:

ProviderManager.addIQProvider(“notifications”,
“androidrs:iq:notifications”,
new NotificationIQProvider());

You need o register an IQ request handler:https://www.igniterealtime.org/builds/smack/docs/4.1.7/javadoc/org/jivesoftware/ 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);
}

@Override
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(

NotificationIQ.ELEMENT,
NotificationIQ.NAMESPACE,
IQ.Type.set,
null));

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.

configBuilder.setResource(“Smack”);

While It is automatically set by library in aSmack.

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

171762@xxx.xxx.openfire/2141cde9

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

171762@xxx.xxx.openfire/Smack

Thank you all the same!