How to use IQ stanza to request for data and get a response

Hey guys,

I’m trying to make a xmpp client with smack api. Here’s my idea : I want to use jmeter to send a raw xml that would look something like this

<iq to="user1@server" from="user2@server" type="set" id="light"> </iq>

I made a StanzaListener with StanzaIdFilter that will take stanzas only with id=“light”. And my processStanza method currently looks like this:

@Override
    	public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException, NotLoggedInException {
    		System.out.println("New stanza from " + packet.getFrom());
    		IQ iq = (IQ) packet;
    		if(iq.isRequestIQ()) {
                       //send any packet right now, just for testing
    			IQ resultIq = IQ.createResultIQ((IQ) packet);
    			connection.sendStanza(resultIq);
    		}
    	}

I enabled debugger like this : SmackConfiguration.DEBUG = true; and when i send a message type or pressence type everything works fine. But when i send iq type i just don’t receive any packets.
I’m still not quite familiar with the iq stanza xml format, but i hope you understood what i want to accomplish here.

1 Like