powered by Jive Software

Why the roster isn't added on both the sides?

user-a sends a subscription request to user-b. Subscription mode has been set to accept_all. Also, packet listener has been registered for both the users.

When user-a sends a request to user-b this method is called :

private void searchUser(java.awt.event.ActionEvent evt) { try { String userToSearch = jTextField1.getText(); if(!xmppParamInit) { initUXmppP(); xmppParamInit = true; } Presence subscribe = new Presence(Presence.Type.subscribe); userToSearch += "@localhost"; subscribe.setTo(userToSearch); ofConnection.sendPacket(subscribe); // Send the 'subscribe' packet }catch(Exception exc) { exc.printStackTrace(); } }

Prior to this method, following are called :

`private void startPLThread() { // start packet-listener-thread
Runnable r = new Runnable() {
public void run() {
new Thread(r,“packet listener thread”).start();

private void startPL() {
PacketListener pListener = new PacketListener() {
public void processPacket(Packet packet) {System.out.println(“Inside process packet”);
if(packet instanceof Presence) {
Presence presence = (Presence) packet;
Presence subscription = new Presence(Presence.Type.subscribe);
System.out.println("presence.getFrom : " + presence.getFrom());

PacketFilter pFilter = new PacketFilter() {
    public boolean accept(Packet packet) {
        return true;

ofConnection.addPacketListener(pListener, pFilter);


The problem is user-a can see user-b in his roster but user-b cannot see user-a in its roster. I do not understand the reason for this. What could be the problem ?

Subscription mode has been set to accept_all in this method that is called from within search user :

private void initUXmppP() { // Initialize user-xmpp-parameters Roster roster = ofConnection.getRoster(); roster.setSubscriptionMode(Roster.SubscriptionMode.accept_all); }

It is a GUI application and I tried keeping both the users online