There seems to be a problem getting the list of subscribers of a pubsub node. getSubscriptions only returns the list of subscriptions for the current user, where as the spec says it should return all users that are subscribed to the node.
As per XEP-0060 “XEP-0060: Publish-Subscribe” the request namespace should be “http://jabber.org/protocol/pubsub#owner ” where as the request sent by smack is “http://jabber.org/protocol/pubsub ”
REQUEST:
<pubsub xmlns='[http://jabber.org/protocol/pubsub](http://jabber.org/protocol/pubsub)'>
RESPONSE:
<pubsub xmlns='[http://jabber.org/protocol/pubsub](http://jabber.org/protocol/pubsub)'>
I noticed this in 4.0.6 and also 4.1.0-alpha6.
CSH
January 1, 2015, 12:44pm
#2
I think this method covers the following use case:
XEP-0060: Publish-Subscribe
2 Likes
Oh ok. Any idea how I can get all subscribers to a node?
Flow
January 1, 2015, 1:38pm
#4
AFAIK there is currently no API for that. I’ve created SMACK-623 to track that and will upload a new version of 4.1.0-alpha7-SNAPSHOT soon.
Just to clarify, does this mean 4.1.0-alpha7-SNAPSHOT will have a new API to get a list of all subscribers of a node?
Flow
January 1, 2015, 2:17pm
#6
Uploaded a new snapshot with: https://github.com/Flowdalic/Smack/commit/2b7e0ba961f7e2464f98f5b7fe073ea89c702a 41
Please test and report back if it works for you.
I am trying to use the new latest snapshot, but looks like XMPPTCPConnectionConfiguration.XMPPTCPConnectionConfigurationBuilder is not defined.
Its available in alpha6.
Please disregard my last. Found XMPPTCPConnectionConfiguration.Builder in the code.
I get the following exception.
Exception in thread “main” java.lang.NullPointerException
at org.jivesoftware.smackx.pubsub.Node.getSubscriptions(Node.java:229)
at org.jivesoftware.smackx.pubsub.Node.getSubscriptionsAsOwner(Node.java:212)
at org.jivesoftware.smackx.pubsub.Node.getSubscriptionsAsOwner(Node.java:184)
at Client41.main(Client41.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
In the debug window I can see all the subscriptions in the raw received packets.
Flow
January 1, 2015, 3:11pm
#10
It appears the subscriptions sub element is not returned. Could you show me the request and reply stanzas?
Request:
<pubsub xmlns='[http://jabber.org/protocol/pubsub#owner](http://jabber.org/protocol/pubsub#owner)'>
Response:
<pubsub xmlns='[http://jabber.org/protocol/pubsub#owner](http://jabber.org/protocol/pubsub#owner)'>
On line number 228 in Node.java
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
where
PubSubElementType.SUBSCRIPTIONS(“subscriptions”, PubSubNamespace.BASIC),
But for getSubscriptionsAsOwner it should have been
SUBSCRIPTIONS(“subscriptions”, PubSubNamespace.OWNER),
I guess thats why subElem is null.
Flow
January 1, 2015, 5:00pm
#13
1 Like
It works. Thanks a lot Flow
Flow
January 1, 2015, 5:39pm
#15
But for getSubscriptionsAsOwner it should have been
SUBSCRIPTIONS(“subscriptions”, PubSubNamespace.OWNER),
I guess thats why subElem is null.
Nope, that’s actually a little flaw in the PubSub implementations design. NodeExtension, the superclass of SubscriptionsExtensions, uses a namespace when it actually has only an implicit one inherited from the pubsub element.
Flow
January 1, 2015, 5:39pm
#16
You are welcome. And thanks for reporting.