When multiple users send room message, it found "Client is not, or no longer, connected" exception


My openfire sever version is 3.10.0, and smack version is 4.1.0, and my openfire server machine CPU is 2.6GMZ, and the memory is 8G.

When I use one user to send room message is OK, but when I use multiple users to send room message, it sometimes will found the “Client is not, or no longer, connected” exception.

Is it possible a performance problem? but it just only 2 user. Or I have something wrong?

Please help, the problem trouble me a long time, thanks.

My Java code as follow:

I write a connectPool to keep the user connections, but it not work.

private ConcurrentHashMap<String, XMPPTCPConnection> connectPool = new ConcurrentHashMap<>();

public synchronized XMPPTCPConnection getConnection(String userName) throws Exception {

XMPPTCPConnection connection = connectPool.get(userName);
log.debug(String.format(“connection:%s”, connection));
if (connection != null && connection.isConnected()) {

log.debug(“use old connection”);
return connection;

log.debug(“use new connection”);
connection = createConnection(userName, defaultPassword);
log.debug(String.format(“connection is connect:%s”, connection.isConnected()));
connectPool.put(userName, connection);
return connection;

private XMPPTCPConnection createConnection(String userName, String password) throws Exception {

XMPPTCPConnectionConfiguration connectionConfig = XMPPTCPConnectionConfiguration.builder()

.setUsernameAndPassword(userName, password)







return new XMPPTCPConnection(connectionConfig);

Send room message code as follow, I retry 3 times to send the messages, but it seem not work.

public void sendRoomMessage(String roomName, String userName, String message, int retryCount) throws Exception {

try {

log.debug(String.format(“room name:%s, retry %d times”, roomName, retryCount));
XMPPTCPConnection connection = chatConnectionPool.getConnection(userName);
MultiUserChatManager mucm = MultiUserChatManager.getInstanceFor(connection);

MultiUserChat muc = mucm.getMultiUserChat(ChatUtil.fullRoomName(roomName, serverName));

// sleep to make user join to room first
} catch (Exception e) {

if (retryCount == SEND_ROOM_MESSAGE_RETRY_TIMES) throw e;
sendRoomMessage(roomName, userName, message, ++retryCount);


The log as follow:

2015-05-05 17:08:58,542 DEBUG service.ChatService:(ChatService.java:97)

  • room name:room1_key, retry 3 times

2015-05-05 17:08:58,995 DEBUG ChatConnectionPool:(ChatConnectionPool.java:36)

  • connection:org.jivesoftware.smack.tcp.XMPPTCPConnection@274d9652

2015-05-05 17:08:58,995 DEBUG ChatConnectionPool:(ChatConnectionPool.java:38)

  • use old connection

2015-05-05 17:08:59,057 ERROR aspect.ControllerAspect:(ControllerAspect.java:24)

  • sendRoomMessage error: Client is not, or no longer, connected

org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected

    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1226)

    at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfApprop riate(XMPPTCPConnection.java:336)

    at org.jivesoftware.smack.AbstractXMPPConnection.sendStanza(AbstractXMPPConnection .java:609)

    at org.jivesoftware.smackx.muc.MultiUserChat.sendMessage(MultiUserChat.java:1577)

    at service.ChatService.sendRoomMessage(ChatService.java:102)

Anyone can help?Thanks.