Discovering Services

In my previous blog entry, I mentioned that you need to find out if a server supports pubsub. To do that you can use Pidgin’s XMPP Service Discovery Plugin. You can also use Smack to retrieve a list of supported services. Here is the code snippet that will retrieve a list of items/services that a server supports

//Connect and login
XMPPConnection conn = …

ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(conn);
//Assuming that we are querying
DiscoverItems items = mgr.discoverItems(“”);
Iterator<DiscoverItems.Item> iter = items.getItems();
while (iter.hasNext()) {
   DiscoverItems.Item i =;

This will produce the following from

<item jid=””/>
<item jid=”” name=”Multi-User Chat”/>

Once you have this list, you can now use the JID enteries to retrieve other services. For example, notice that supports multiuser chat (MUC) with JID We can now use this JID to get a list of rooms, configurations, etc.

Connecting to Google Talk produce the following

Exception in thread “main” feature-not-implemented(501)
   at org.jivesoftware.smackx.ServiceDiscoveryManager.discoverItems(

Clearly Google has implemented a no frills server; Google Talk only support 1 to 1 chat and nothing else. BTW to connect to Google talk, use the following code snippet

ConnectionConfiguration config = new ConnectionConfiguration(
      “”, 5222, “”);
XMPPConnection conn = new XMPPConnection(config);
//Note you MUST have ‘’ to login
conn.login(“”, “your password”);

And finally here is the list of services from an instance of openfire running on my notebook

<item jid=”pubsub.batcomputer” name=”Publish-Subscribe service”/>
<item jid=”search.batcomputer” name=”User Search”/>
<item jid=”conference.batcomputer” name=”Public Chatrooms”/>
<item jid=”proxy.batcomputer” name=”Socks 5 Bytestreams Proxy”/>

Notice that pubsub JID which is exactly the service we were trying to connect with PubSubManager.

%d bloggers like this: