powered by Jive Software

Subscribe problem


i have a problem…

when a user adds me to his roster i show in his roster without accepting the subscribe request at first.

and also when i add some user he is automaticlly showed

in my roster.

now my question is this:

what about the subscribtion !!!

and what is the MANUAL thing…

can any 1 explain me??

Hey Gil,

Every time you add someone to your roster you will do two things. 1) Update your roster configuration in the server with the new entry and 2) Send a presence subscription to the user that has just been added to your roster.

You can configure Smack to accept all subscription requests, reject all subscription requests or you can choose to manually process all subscription requests. If you choose to manually process all subscription requests, a PacketListener should be registered that listens for Presence packets that have a type of SUBSCRIBE. By default, Smack will accept all subscription requests.


– Gato

i have this code …

and yet…

an exodus client(for example) when he adds me:

first i am viewed at his list

then i get the question…(see at the code)…

// Presence listener

presListener = new PacketListener() {

public void processPacket(Packet packet) {

Presence presence = (Presence) packet;

// If we got request to subscribe ,we’'ll show the

// request

if (presence.getType() == Presence.Type.SUBSCRIBE) {

String from = presence.getFrom();

int accept = JOptionPane.showConfirmDialog(null,



//We accept the request

if (accept == JOptionPane.YES_OPTION) {





// Now will add to our roster





if (accept == JOptionPane.NO_OPTION) {









is this good? because it sure aint working right…

i also did the

roster.setDefaultSubscriptionMode(Roster.SUBSCRIPTION_MANUAL );

i think that the line

roster.setDefaultSubscriptionMode(Roster.SUBSCRIPTION_MANUAL )

does’'nt work…

because an exodus client adds me and my presence in his list is online and all that is accure before i accept the request… so i think that perhaps my client behave like automatic and not manual


I’'m not sure I understand the problem you are describing. However, I found a possible error in the listener code.

You are using the same presence in order to accept the subscription request and to add the new user to your roster. Since you are using the same presence instance, you are modifying the presence’'s type from SUBSCRIBED to SUBSCRIBE before Smack can actually send the first configured presence. The correct way to add a new entry to your roster is to use Roster.createEntry.


– Gato

but all the sxamples uses this code…

Which examples are you referring to?

– Gato

in all sources i saw the

way to send first the subscribed presence and then the

subscribe presence to add to our list.

but any way thats not the problem because when i use the exodus client and i add a user (which is my handeld by my program) the exodus adds the user directly with his presence before the client(which is run under my program) accept the request.

thats why i said that maybe the line of the request manual doesnt work… because the exodus client managed to add the user without his authorization.


I think that there is a misunderstanding. You can’‘t prevent a user from adding another user to his/her roster. AFAIK, the XMPP protocol does not specify that the “added user” has a chance to authorize or not the operation. The XMPP protocol allows you to accept presence subscriptions. This means that if someone adds you to his/her roster and you don’‘t accept the presence subscription, the other person won’'t know when you are online or offline but you will be part of the roster.

If you suspect that the client exodus is receiving a presence acceptance from Smack, I recommend to open a debugger to detect when Smack accepts the presence subscription. Is it possible that you are setting the SUBSCRIPTION_MANUAL mode too late? (i.e. after you have made log in)


– Gato

when do i have to do this…

i used it after i created the roster…

i did



is that too late…?

or maybe i had to do this after i loged in…

(but then i dont have a roster )…

or maybe it is a static function?


If you are going to change the default subscription mode then I recommend to set the new subscription mode before you log in to the server. To set the default subscription processing mode to use when a new Roster is created use the static Roster.setDefaultSubscriptionMode method.


– Gato