Hi,
First of all I would like to thank you for the great job that you have done by porting the Smack library to the Android platform, nevertheless I have a problem with it.
The problem is related to publish/subscribe service of XMPP. In fact, when I try to use publish/subscribe service on Android 2.1 with asmack-2010.04.02.jar I get a ClassCastException, while if I try the same code on the PC, with the smack from SVN (r11655), it works perfectly. I have attached an Android class that tries to use the publish/subscribe service by subscribing to a node as example (see nomeclasse.java). Also, the Android log is attached (see Debug.rtf).
As you can see from the log the exception is thrown by the instruction: eventNode = manager.getNode(PUBLISHER_NODE). Do you have any idea to fix the issue? Am I doing something wrong?
P.S.: I left the crediantials to the server as plain text, to give you a chance to use my OpenFire server. Please don't warry about the credentials because it is a dummy account on a testing server.
Thank you, Selene
- Debug.rtf 13.76KB
- TestAsmack.zip 845.1KB
Comment #1
Posted on Apr 6, 2010 by Grumpy RhinoAsmack doesn't come with auto-registration for packet extensions. You have to register the classes.
You may steal the code from [http://code.google.com/p/buddycloud/source/browse/trunk/client/android/main/src/com/buddycloud/jbuddycloud/BuddycloudClient.java#49 Buddycloud] or rewrite the [http://github.com/rtreffer/smack/blob/master/build/resources/META-INF/smack.providers smack xml config].
Comment #2
Posted on Apr 6, 2010 by Grumpy RhinoI'm too incompetent at using the reply box, but the problem should be solved. Don't hesitate to open up a new issue when you run into problem :-)
Comment #3
Posted on Apr 7, 2010 by Swift HippoHi rtreffer, Are you going to add a patch to asmack that manually register all the packet extension available on smack, so that other users of your library won't have to face this issue?
Are there any drawbacks if I register all the packet extension, even if I don't use some packet?
Does Buddycloud register all the packet extension or only a part of packet extension of smack?
Best regards, Stefano "Kismet" Lenzi
Comment #4
Posted on Apr 7, 2010 by Grumpy RhinoI'm trying to use only the needed extensions, as XMPP is mainly running as a background service, meaning a memory leak might be fatal.
Besides that: I'm seeing several missuses of the lib, but I'll not try to solve all of them in the lib. I'll try to create a simple sample app with all the bits needed. This should help as a kickstartet for others.
Regards, René
Comment #5
Posted on Apr 7, 2010 by Swift HippoHi Renè,
Does it means that asmack aims at be a system Service and that android Application (may I say Activities) should interact with asmack by means of Intent?
Comment #6
Posted on Apr 7, 2010 by Grumpy RhinoIt's just a lib. Which is "usually" used inside a service. The service writes to a content provider, and activities that attach to these content providers.
That's the way most xmpp apps are modeled atm.
That said asmack is (right now) jast the xmpp library :-)
Comment #7
Posted on Apr 15, 2010 by Helpful KangarooI downloaded last source from repository and patched, some patch manually.... but im getting the same problem..(CastException) in getNode. How can i fix this ?
Comment #8
Posted on Apr 15, 2010 by Grumpy RhinoAs I've said you should track the connection process and make sure the pubsubmanager is registered (together with the pubsub elements). I'm actually doing pubsub all the time, for buddycloud. It's definetly working once the IQProviders are registered.
The ProviderManager must be able to resolve the pubsub items/namespaces. You'll otherwise end up with a generic packet that can't be casted (obviously).
Have a look at this static bock on how to do it: http://code.google.com/p/buddycloud/source/browse/trunk/client/android/main/src/com/buddycloud/jbuddycloud/BuddycloudClient.java#45 You should register anything from the pubsub namespace and from org.jivesoftware.smackx.pubsub.
This has to happen before you try to connect to the server.
Comment #9
Posted on Apr 22, 2010 by Swift HippoHi one2one,
I don't know if you resolved your problem but you can copy and paste the code that you find attached to comment #14 of the issue #9 [1] to initialize ASmack to support XEP-0060: Publish-Subscribe
Ciao, Stefano "Kismet" Lenzi
[1] - ASmack initalization for enabling support fo XEP-0060 - http://asmack.googlecode.com/issues/attachment?aid=1025499906583360115&name=asmack.initialization.java
Comment #10
Posted on Dec 3, 2011 by Quick CatEverytime I try to get a node, I get item-not-found. Even when I create the node before, and I get no errors. Can you help me? Almost all the links that you posted are down. Thanks.
Comment #11
Posted on Apr 24, 2012 by Happy RabbitThe above issue is resolved using the help i got from this site.
http://community.igniterealtime.org/message/201866#201866 use the code in above site to register all the providers
also Servicediscoverymanager was returning null which was causing problem
so i replaced
ServiceDiscoveryManager discoManager =ServiceDiscoveryManager.getInstanceFor(connection);
with
ServiceDiscoveryManager discoManager = new ServiceDiscoveryManager(connection);
Status: Done
Labels:
Type-Defect
Priority-Medium