Issue with subscription, ask and recv fields in Openfire database

Hi All,

We are using Openfire 4.0.3 for chat communication in our API application. Openfire is maintaining one database for chat purpose.
In that database there is ofRoster table which stores the users and their contact list.
The structure of table is:

CREATE TABLE [dbo].[ofRoster](
[rosterID] [int] NOT NULL,
[username] nvarchar NOT NULL,
[jid] nvarchar NOT NULL,
[sub] [int] NOT NULL,
[ask] [int] NOT NULL,
[recv] [int] NOT NULL,
[nick] nvarchar NULL)

I am unable to understand the clear purpose of sub, ask and recv fields. When we add a contact to the user, it is randomly selecting the values for sub, ask and recv.
So far I have seen possible values :
Sub = 0 - None, 1= To, 2 = From, 3 = Both, -1 = remove
ask= -1 ?, 0= subscribe, 1= ?

Moreover, the contact disappears from the contact list of user when the roster table has a combination (0,-1,-1) for (sub,ask,recv). This is the primary issue i am investigating. Could anybody please help me understand in what case we will have this combination in the database amd whether it is per design that the user should not be displayed in the contact list if he has such combination.

Your quick response is highly appreciated.

Thank you
DR

I can’t answer all these questions as i don’t know the under the hood technical stuff, but when a user adds a contact to his/her roster, a subscription request is sent to that contact to approve. This means that the first user won’t see other user’s presence information (online/away/offline) until that user approves it. There is a plugin Subscription for Openfire, which does this automatically for all users.

1 Like

Hi Spark

Thank you for your reply.

I understand the subscription part but that is managed through subscription
column in the database. I am unable to understand the combination of sub,
ask, recv which is (0,-1,-1).

Please help me understand the purpose of this and in what case we will have
this in the db.

Thank you so much
DR

They reflect the subscription states, see here:

https://xmpp.org/rfcs/rfc6121.html#substates

I can’t tell what the values really mean, but my guess is:
sub = the susbcription state (as reflected in each roster item)
ask = Might be “Pending In” state
recv = Might be “Pending Out” state, I think it’s used to resend presence subscription requests, when the recipient logs in.

It’s only a guess. I feel the roster table is not designed very intuitively.

1 Like

Thank you CHS,

I have gone through this, but looking for how exactly each of these are mapped in the Openfire database - OfRoster table.

That would really help me understand the behaviour and how states and subscriptions are managed internally. Something like:

Sub ask recv Interpretation
0 0 -1 what it means if this combination exist in the Openfire database
0 1 -1 All such combinations of these 3 fields with their interpretation
0 -1 -1
0 0 1
0 1 1
0 -1 1
0
1 0 -1
1 1 -1

If you could please share any ideas around this, that will be great help.

Warm Regards
DR

I have understood the interpretation of tehse values but in what case I will get sub=0, ask=-1 and recv=-1
If anybody can help me understand, that will be great.

Thanks in advance,

I’d say when a user adds a contact to his contact list, but doesn’t send a presence subscription request. (sub=0: no subscription, ask=-1: didn’t ask/no pending out request, recv=-1: nothing to receive for the contact).

But it’s really only a rough guess. To really find out, you must test it out.