Smack behavior for multithreaded environment


I have recently started using Smack 4.0.5 version as a client for my openfire server. I have just completed a basic implementation of (1) createAccount API using Smack (2)adding users to a particular roster and all my unit test cases passed. I then exposed this createAccount API as a restful interface.But just to check the performance . I ran a JMeter load test by spawning 1000 concurrent requests to create users in openfire. This is where the problem begins. , Although a lot of requests seems to be going through I started observing the following exceptions


at org.jivesoftware.smack.PacketCollector.nextResultOrThrow( 91)

at org.jivesoftware.smack.PacketCollector.nextResultOrThrow( 75)

at org.jivesoftware.smack.Roster.createEntry(

at com.hp.userservice.dao.impl.ProvisioningDAO.addUserToMerchantRoster(Provisionin

at com.hp.userservice.dao.impl.UserServiceAdministrationImpl.createUser(UserServic

Connection closed with error

stream:error (conflict)

at org.jivesoftware.smack.tcp.PacketReader.parsePackets(

at org.jivesoftware.smack.tcp.PacketReader.access$000(

at org.jivesoftware.smack.tcp.PacketReader$

2014-11-12 13:25:36 INFO com.hp.userservice.dao.impl.ProvisioningDAO:157 - User created successfully in OF_USER table in openfire

Exception writing closing stream element Software caused connection abort: socket write error

at Method)



at sun.nio.cs.StreamEncoder.writeBytes(

at sun.nio.cs.StreamEncoder.implFlushBuffer(

at sun.nio.cs.StreamEncoder.implFlush(

at sun.nio.cs.StreamEncoder.flush(



at org.jivesoftware.smack.tcp.PacketWriter.writePackets(

at org.jivesoftware.smack.tcp.PacketWriter.access$000(

at org.jivesoftware.smack.tcp.PacketWriter$

These errors seems to be occurring even for 50 concurrent users.

This is my Code :

//Obtaining XMPPCOnnection

public XMPPConnection connectToOF() throws ConnectionFailedException{

configuration = new ConnectionConfiguration(OFHost, OFPort);






connection = new XMPPTCPConnection(configuration);

try {


return connection;

} catch (XMPPException | SmackException | IOException e) {

log.error(“Error while obtaining the connection to Openfire.”);


throw new ConnectionFailedException(ErrorCodes.OPENFIRE_SERVER_UNREACHABLE);


//Creating Account

AccountManager manager = connectionObj.getAccountManager();

Map<String, String> registrationMap = new HashMap<String, String>();

registrationMap.put(“name”, userObj.getAlias());

registrationMap.put(“email”, userObj.getEmailId());

try {

manager.createAccount(userName, password, registrationMap); //ofuser create account

}catch(Exception e){


//Roster Snippet

Roster roster = xmppconnection.getRoster();

String groupName = null;

if(userObj.getGroup() == null )

groupName = userObj.getAppid();


groupName = userObj.getGroup();

RosterGroup rgroup = roster.createGroup(groupName);

if(rgroup !=null)return true;


return false;


I need to know under what circumstances are the exceptions raised. Are there any performance benchmarks already available, Is there any particular configuration I need to do in my code to ensure such errors dont arise ?

NoResponseExceptions is self explanatory. And the reason for a stream error of type ‘conflict’ can be found in the XMPP RFC: Extensible Messaging and Presence Protocol (XMPP): Core

It bet your problems come because you re-use the same fullJID, i.e. the same bareJID and resource, for the connections.


Thanks for your response. I have also tried modifying the resource by adding an AtomicIntegers to the resourceIdentifier and yet the same exception occurs. the stream conflict seems to be reduced but the org.jivesoftware.smack.SmackException$NoResponseException still continues.

Thanks for the help. I really appreciate it.