powered by Jive Software

Service Discovery & Packet Listener conflict?

I have an XMPP service that is designed as a “hub” to coordinate some other connected services. The idea is that those other services use the Service Discovery Manager to add a set of strings representing features. They do this after getting an XmppConnection but before logging in:

ServiceDiscoveryManager sdm = ServiceDiscoveryManager

.getInstanceFor(xmppConnection);

String[] funx = functions.split("[, ]+");

for (int i = 0; i < funx.length; i++)

{

dbg("Adding " + funx+);

sdm.addFeature(funx+);

}

The “hub” service may then require one of those features so it uses Service Discovery to locate a service that provides it:

ServiceDiscoveryManager sdm = ServiceDiscoveryManager

.getInstanceFor(xmppConnection);

dbg(“locateProvider attempting to find provider for service <” + service

  • “>”);

DiscoverItems di = sdm.discoverItems(service); // BREAKS HERE

for (Iterator it = di.getItems(); it.hasNext():wink:

{

It throws an exception at the point marked above:

(502) Unable to resolve hostname.

at org.jivesoftware.smackx.ServiceDiscoveryManager.discoverItems(ServiceDiscoveryM anager.java:399)

at org.jivesoftware.smackx.ServiceDiscoveryManager.discoverItems(ServiceDiscoveryM anager.java:365)

On the Hub side I see a “DiscoverItems” packet being detected by the packet filter but it’‘s rejecting it. Probably this is the cause - I think maybe I shouldn’'t be using high-level extensions like Service Discovery and low-level stuff like packet filters at the same time.

The trouble is I need the packet filter and listener to handle the other messages that go between the hub and the other services. Or do I? Is there another way I should be handling this?

Hey Pete,

XMPP requires that the client must be logged in and authenticated before sending any disco packet to the server. BTW, is the +service +variable a valid JID? Cause the disco packet is going to be sent to that address so you need to be sure that it points to a valid JID.

Regards,

– Gato

I was assuming that, because you are allowed to add the features before logging in, this means that the feature data is then made available to other services as soon as you log in. This is important to our application because a service providing a specific feature may be interrogated the instant it logs in, so the information must be available right away. The documentation seems to be a bit lacking in describing exactly how this works.

Hey Pete,

You are correct. The ServiceDiscoveryManager#addFeature(String) message may be sent before you have logged into the server since no packet is sent to the server. I will enhance the method comment to make that clear. But remember that you must be connected with the server if you want to discover information or items about other entities.

Thanks,

– Gato