Find users across server

Dear Community!
I am currently trying to understand how openfire works and i was now wondering, how does openfire save, to which server a users was logged in? Does it stay the same server, no matter where the user is currently only depending on the first login or does it change for example when the user first has logged in at the server in europe and later connects to the server in the usa? If it stays the same, how can i retrieve which @ a users has logged in first so i can send messages? If this has not changed, how do i keep track of where the user is now? How can i search for the server a user is so that other users can send messages to him?

I am not sure i understand your question, but if you mean how XMPP in general works: User creates an account on lets say, his JID will all his contacts will be saved at the server, chats might or might not be stored on the server(depending on the server settings).
if have a friend in another server both servers will communicate with each other and relay the messages. however if lets say happens to be offline for any reason, user1 will not be able to communicate with no one. and will not be able to send messages to

That goes in the right direction. My point is now where is stored, that friend is at server2? And when server2 for example is in the us and server1 in EU, when friend now goes to the EU is hi address still friend@server2 or does it switch to friend@server1 as he is near the other server now?

And now when i am creating a chat app to connect to the openfire server, do i manually need to keep track of the servers of the users? Like when user1@example1 wants to write friend@server2 but only has the username being friend, how can i find out if friend ist now at sever1 or server2? Can openfire find that out? Do i have to save the servers?

If your friend is connected to a different server(different domain) it will never change. it doesn’t matter if he moves or not. his client will always connect to the same domain.

@zoidberg is pretty much on the money here. Let me rephase what he’s saying.

An XMPP user has an account on an XMPP service. To identify the account, a “jabber identifier” (JID) is used, which has the form of user@service.

A user on service might thus have a JID that is When a user exists on a different service, they will have a different JID (for example,

Users typically maintain a contact list, or ‘roster’, of people that they are communicating with. This list is basically a list of JIDs. When sending data to each-other, clients use data packets (“stanzas”) that have a ‘to’ and ‘from’ address in the form of a JID.

When Alice sends a message to Bender:

  • Alice’s client will always deliver that message to her own service ( for further processing. This uses the client-to-server connection between Alice’s client and her service.
  • Alice’s service will evaluate the addressee ( and will determine that this is not a local address. It therefor connects to the service at and forwards the message to that service. This uses a server-to-server connection.
  • The service will process the message that it received from the service, determine that the addressee is a local user, and deliver the message to that user (or schedule it for delivery if that user is currently offline). This again uses a client-to-server connection.
1 Like