How can i create , send and receive raw iq Packet

how can i create , send and receive raw iq Packet

following is my code and i am not able to receive iq packet at psi client

public class POSClientIQ
{

public XMPPConnection connection;

  public static void main(String args[])
  {
      POSClientIQ posclientiq = new POSClientIQ();
      posclientiq.connectXMPPServer();
      posclientiq.processMessage();

  }
 
  public void processMessage()
  {        try{
     
        final  IQ iq1 = new IQ() {
          public String getChildElementXML() {
        return "<iq type='get' from ='sam@intime-hardik'><query xmlns='jabber:iq:roster'></query></iq>";
      }
    };
   
    iq1.setType(IQ.Type.GET);
    connection.sendPacket(iq1);

}

I am not receiving iq msg as i have 5 users conected at my XMPP server

I am already connected to server when run above code following ouput

Client login in XMPP server success
Message send

You have to exclude the iq node. Your xml should look like this

<query xmlns='jabber:iq:roster'></query>

You can also open the debugging window by settin;

static {
    XMPPConnection.DEBUG_ENABLED = true;
  }

Hi,

to create a raw packet you must implement #getChildElement() and just return null.

public void processMessage() {
    IQ iq1 = new IQ() {
        public String getChildElementXML() {
            return null;
        }
    };
    iq1.setFrom("sam@intime-hardik");
    iq1.setType(IQ.Type.GET);
    connection.sendPacket(iq1);
}

Best regards,

Henning

Yeah it helped me. But i am unable to receive iq packets other than roster. And that to not in a sequence. I implemented packet listener and stuff

I need to send an IQ stanza from client to server via smack and get back the response from server it is quite similar to your task. If you have got the solution to the above problem can you plz help me.

Plz share client code with me if u can.