Customize the messages

Hi everyone, I want to use the StanzaCollector and StanzaListener to process the packets.
I also want to catch the message that the debugger catches when setting the setDebuggerEnabled is true.
I use the Smack version is 4.2.3
Here is my code:

import java.io.IOException;

import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.StanzaCollector;
import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;

public class SmackClient {
    public static void main(String []args) throws InterruptedException {
        
        // Create a connection and login to the example.org XMPP service.
        XMPPTCPConnectionConfiguration config;
 
        try {
            config = XMPPTCPConnectionConfiguration.builder()
                    .setUsernameAndPassword("admin", "password")
                    .setHost("144.202.36.197")
                    .setXmppDomain("localhost")
                    .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
                    .setPort(5222)
                    .setDebuggerEnabled(false)
                    .build();

            AbstractXMPPConnection conn2 = new XMPPTCPConnection(config);
            StanzaFilter filter = new AndFilter(new StanzaTypeFilter(Message.class));

            StanzaCollector myCollector = conn2.createStanzaCollector(filter);
            StanzaListener myListener = new StanzaListener() {
                public void processStanza(Stanza stanza) {
                    // Do something with the incoming stanza here._
                    System.out.println(stanza.toString());
                    try {
                        myCollector.wait();
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            };
            conn2.addSyncStanzaListener(myListener, filter);
            conn2.connect().login();
        } catch (XMPPException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SmackException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

Unfortunately, my code is not worked well and I cannot receive any debugged messages.
What’s wrong with this code?

Thanks.

You block indefinitely in a sync stanza listener.