“Priority” and “Resource” in XMPP

jabberprotocolxmpp

I don´t know if those are the names in english, but it spanish is "Prioridad" and "Recurso". I see this when I want to configure an XMPP client. In "Priority" I see that I have to put a number, and I suppose (I´m not sure) that depending on the number the messages will get on the account with the highest number, or is it the other way around?
And in "Resource" I don´t have a theory, for example when I configure my Jabber account on Thunderbird, by default the resource is "Thunderbird", and when it is on ChatSecure, the resource is "ChatSecure-12345678"[1]
I´ve not found any documentation about this in the Web. Where can I read about this?

[1] The "12345678" is a random set of numbers and letters, which are always 8, and they are different of the other accounts (this only in happens in ChatSecure)

Best Answer

Priority and Resource are relevant when you are online with multiple clients (with the same JID).

Let’s say your JID is alice@example.net and you are online with two clients:

  • Client 1
    Priority: 5
    Resource: home

  • Client 2
    Priority: 7
    Resource: mobile

If someone sends a message to alice@example.net/home,
you will receive it on Client 1.

If someone sends a message to alice@example.net/mobile,
you will receive it on Client 2.

If someone sends a message to alice@example.net,
you will receive it on Client 2, because it has the higher priority.

tl;dr: The Resource allows the sender to identify/target specific clients, and the Priority decides which client will be used in case the sender doesn’t target a specific Resource.


The Priority can go from -128 to 127. If you set a negative Priority (e.g., -1), this client will never receive a message unless the sender explicitly sends it to that’s client Resource. If the clients have the same positive Priority, all of them should get the message.

Some clients append random strings to the Resource (probably what ChatSecure does) to make the full JID unpredictable, which can be relevant for security reasons.

Related Question