powered by Jive Software

How to force a user disconnect from openfire?


I would like to know how to force a user to disconnect from openfire?



On the sessions tab click the ‘close connection’ image.

a.nielsen wrote:

On the sessions tab click the ‘close connection’ image.

As he is posting in Dev forum, i thought he needs a programatic solution. Have to add, that if client is set to reconnect, it will connect again if his session was just closed on the Sessions page. But there are other ways (but i can’t say how to do this) to disconnect. E.g. if you login with the same login on second client, then first client is disconnected and even doesnt try to reconnect, so it must be getting some special command in that case. One more way to disconnect a client is to use a Lock out feature in user’s account settings in Admin Console.

how to do that inside code, for example, an openfire plug in, is there such API for doing this? thanks

Not sure if this is 100% relevant, but we use this code in our authentication plugin, to kick existing users if a user logs in from another location:

// Kick all users with the given username, giving them the name-conflict error. private void closeConflictingConnections( String username ) {
      // Kick out the old connection that is conflicting with the new one
      StreamError error = new StreamError(StreamError.Condition.conflict);
      // Find the user's sessions
      Collection<ClientSession> sessions = SessionManager.getInstance().getSessions( username.toLowerCase() );
      if( sessions != null ){
           // Close all sessions for the given username
           for( ClientSession session : sessions ) {
                session.deliverRawText( error.toXML() );

In our client, we make sure to not automatically reconnect if the “conflict” error is received. I believe if you are just trying to kick a user verbatim, you could change the error sent.