I have a patch that solve the slow login problem.
The problem is the following:
in the login process, there is a wait() that waits for the server to set the connection id
The problem is though that it can often happen that notify is called befor wait is called, causing
the login to wait until it times out, which happens to be five seconds by default.
That means on fast servers, this method always times out.
Use and enjoy,
andy
here is the function you have to replace in PacketReader.java
public void startup() throws XMPPException {
/* readerThread.start();
listenerThread.start();
// Wait for stream tag before returing. We’'ll wait a couple of seconds before
// giving up and throwing an error.
try {
synchronized(connectionIDLock) {
connectionIDLock.wait(SmackConfiguration.getPacketReplyTimeout());
}
}
catch (InterruptedException ie) { }
if (connectionID == null) {
throw new XMPPException(“Connection failed. No response from server.”);
}
else {
connection.connectionID = connectionID;
}*/
Thread startupThread = new Thread() {
public void run() {
// Wait for stream tag before returing. We’'ll wait a couple of seconds before
// giving up and throwing an error.
try {
synchronized(connectionIDLock) {
connectionIDLock.wait(SmackConfiguration.getPacketReplyTimeout());
}
}
catch (InterruptedException ie) { }
}
};
//first start the thread that waits
startupThread.start();
// then start the thread that will notify
readerThread.start();
//System.out.println(“readerThread strart”);
listenerThread.start();
// System.out.println(“listenerThread strart”);
try
{
//finally, wait for the startup thread to finish, and then all is well
startupThread.join();
}catch(Exception e)
{
e.printStackTrace();
}
if (connectionID == null) {
System.out.println(“connection failed”);
throw new XMPPException(“Connection failed. No response from server.”);
}
else {
connection.connectionID = connectionID;
}
}