Take 21 seconds to register a user

Here is my code:

import java.io.*;

import java.text.*;

import java.util.*;

import org.jivesoftware.smack.*;

import org.jivesoftware.smack.packet.*;

import org.jivesoftware.smack.filter.*;

public class TestSmack extends Thread implements PacketListener

{

public void run()

{

while (true)

{

try

{

Thread.sleep(1000);

}

catch (Exception ex)

{

}

}

}

public void processPacket(Packet p_packet)

{

Message l_message = (Message)p_packet;

PrintLog("XML : " + l_message.toXML() + “\n”);

}

public void registerUser()

{

try

{

PrintLog(“Registering user.”);

XMPPConnection l_xmmpConnection = new XMPPConnection(“192.168.1.5”);

l_xmmpConnection.addPacketListener(this, new PacketTypeFilter(Message.class));

AccountManager l_accountManager = l_xmmpConnection.getAccountManager();

Map l_map = new HashMap();

l_map.put(“name”, “Tan Chen Yee”);

l_map.put(“email”, “tancy@win2000svrw”);

l_accountManager.createAccount(“tancy”, “tancy”, l_map);

PrintLog(“User is registered.”);

}

catch (Exception ex)

{

PrintLog("Exception in registerUser: " + ex.toString());

}

}

public void PrintLog(String p_strStatement)

{

Format l_fmtDate = new SimpleDateFormat("[hh:mm:ss a]");

System.out.println(l_fmtDate.format(new Date()) + " " + p_strStatement + “\n”);

}

public static void main(String args[])

{

TestSmack l_testSmack = new TestSmack();

l_testSmack.registerUser();

l_testSmack.start();

}

}

Here was the response:

E:\Jabber\API\Smack 2.1.0\code>java -classpath …/smack.jar;…/smackx.jar;./ TestSmack

Registering user.

User is registered.

As you can see, it took 21 seconds to register a user. How to shortern the time ?

Server and client PC is connected to a switch. There is not network delay.

Hi Tan,

I tried your code, it runs without problems. I changed the IP address to match the Wildfire “xmpp.domain” name (/server-properties.jsp).

LG

Maybe you can create some more log statements, it is not clear where the time is lost, like:

PrintLog(“Creating connection.”);

XMPPConnection l_xmmpConnection = new XMPPConnection(“jabber.servername”);

// name instead of IP, create it in /etc/hosts if else not resolvable

PrintLog(“conn=”+ l_xmmpConnection.isConnected());

l_xmmpConnection.addPacketListener(this, new PacketTypeFilter(Message.class));

PrintLog(“addPacketListener”);

AccountManager l_accountManager = l_xmmpConnection.getAccountManager();

PrintLog(“AccountManager”);

/code

I tried domain instead of IP, still the same.

public void registerUser()

{

try

{

PrintLog(“Registering user.”);

XMPPConnection l_xmmpConnection = new XMPPConnection(“noneworkstation”);

PrintLog(“Connected.”);

l_xmmpConnection.addPacketListener(this, new PacketTypeFilter(Message.class));

PrintLog(“Added packet.”);

AccountManager l_accountManager = l_xmmpConnection.getAccountManager();

Map l_map = new HashMap();

l_map.put(“name”, “Wong Lee Wei”);

l_map.put(“email”, “wlw08@noneworkstation”);

l_accountManager.createAccount(“wlw08”, “wlw08”, l_map);

PrintLog(“User is registered.”);

}

catch (Exception ex)

{

PrintLog("Exception in registerUser: " + ex.toString());

}

}

Here was the result:

E:\Jabber\API\Smack 2.1.0\code>java -classpath …/smack.jar;…/smackx.jar;./ TestSmack

Registering user.

Connected.

Added packet.

User is registered.

21 seconds were used at XMPPConnection l_xmmpConnection = new XMPPConnection(“noneworkstation”);

Hi Tan,

could you enable the Wildfire debug log and check all the logs? I have no idea why it should take so long. I’'m using java 150_06 and currently a nightly build, but also with 2.1.0 I never saw such problems.

XMPPConnection.DEBUG_ENABLED=true; could help, as the debug windows is displayed after (or while) connecting.

LG

I have set the debug to true :

public void connectJabberTest()

{

try

{

PrintLog(“Connecting.”);

XMPPConnection.DEBUG_ENABLED = true;

XMPPConnection l_xmmpConnection = new XMPPConnection(“noneworkstation”);

PrintLog(“Connected.”);

}

catch (Exception ex)

{

PrintLog("Exception in connectJabberTest: " + ex.toString());

}

}

1st debug window:

3rd debug window is empty.

I don’'t see any error in debug. Do you ?

I tried your code too…

But I got no response from the server

Maybe I am wrong with:

XMPPConnection l_xmmpConnection = new XMPPConnection(“jabber.org”);[/b] ?

Sorry I fixed that on my own…

if you have the same problem try looking on this site:

http://www.xmpp.net/bycountry.shtml

take care flo