SMACK librarary with many clients throws error

Hi,

I am developing a test tool using smack which does

1)Connects a big number of users to openfire server ~400

2)Every users has two timers a) reconnection timer and

b)presence change timer.

These two timers are continously scheduled.

On reconnection timer expiry I do disconnect and reconnect and login the user.

On Presence change timer expiry i do change the presence of that user.

It runs good and fine but after some times i get :

stream:error (conflict)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:260)

at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)

Below is the code snipped

onTimerExpiry() {

if (connection != null && connection.isConnected()) {

connection.disconnect();

}

if (connection != null) {

connection.connect();

connection.login(userName, password, “staticResource”);

}

}

I understand that this happens because the same user is trying to connect again with the same resource, but i do disconnect() before connecting again. The XMPP server which I am using for this test is openfire 3.6.4

Is it the case that even though i call disconnect() it takes some time to actually disconnect() the user and connecting quickly raises this exception.

Please help me in nailing down the problem.

Thanks in advance,

Regards,

Ujjwal