Getting Last Seen/Online-Offline Status for a Roster Entry

Hi.

We are trying to build a feature based on following scenario.

  1. User A registers and logged in to XMPP Server (Openfire in our case) and chat for some time and then logged off.

  2. After some time User ‘B’ registered and logged in to Openfire (User ‘A’ is friend of User ‘B’).

  3. User ‘B’ has User A’s Jabber ID in its Roster.

  4. Now as user ‘A’ is not logged in since long time, user ‘B’ cann’t get its ‘Last Seen/Offline-Online Status’.

We want that user B should get user A’s last status irrespective of whether user A logs in to Openfire after user B’s registration or not. Is there any way to achieve this?

You can query Openfire using XEP-0012: Last Activity

See Example 5.

Hi CSH.

Thanks for the reply.

We have already implemented ‘Last Activity’.

Currently we are getting following exception.

19505-19588/com.appname V/MessagingService﹕ Message:forbidden Error:forbidden

19505-19588/com.appname W/System.err﹕ forbidden

19505-19588/com.appname W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:1 96)

19505-19588/com.appname W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:1 75)

19505-19588/com.appname W/System.err﹕ at org.jivesoftware.smackx.iqlast.LastActivityManager.getLastActivity(LastActivity Manager.java:234)

But until and unless user A accepts subscription request for user B, user B can’t get user A’s ‘Last Seen Status’. We want to overcome this. Without being user A accepts user B’s subscription request, user B should get/fetch/see user A’s ‘Last Seen/Online-Offline Status’. Is there any way possible to achieve this?

Yes, this is normal behavior. XMPP does not allow to see other’s presence information if they didn’t allow you, i.e. if you are not subscribed to their presence.

You probably have to write your own Openfire plugin to do so.

1 Like

you can add presence service plugin and select Everyone in presence visibility. (Server settings-> Presence service->Presence visibility).