-1

I am developing XMPP client for chat.facebook.com on Android. I use X-FACEBOOK-PLATFORM mechanism. According to the server response, I am successfull with authentication. But my JID is strange it is: [email protected]@chat.facebook.com:5222/Application_a573c90d_4E4AD1661EFE6. And my status is always "offline". And rooster is always empty. My LogCat is here:

08-24 14:13:19.920: I/System.out(12326): PRE-CONNECTED
08-24 14:13:19.950: D/dalvikvm(12326): GC_CONCURRENT freed 372K, 5% free 9556K/10055K, paused 2ms+13ms
08-24 14:13:22.540: D/SMACK(12326): 02:13:22 PM SENT (736870032): <stream:stream to="chat.facebook.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
08-24 14:13:22.950: D/SMACK(12326): 02:13:22 PM RCV  (736870032): <?xml version="1.0"?><stream:stream id="67C3CE90" from="chat.facebook.com" version="1.0" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en"><stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-FACEBOOK-PLATFORM</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms></stream:features>
08-24 14:13:22.950: D/SMACK(12326): 02:13:22 PM SENT (736870032): <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
08-24 14:13:23.260: D/SMACK(12326): 02:13:23 PM RCV  (736870032): <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
08-24 14:13:23.280: W/System.err(12326): java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
08-24 14:13:23.280: W/System.err(12326):    at java.security.KeyStore.getInstance(KeyStore.java:119)
08-24 14:13:23.280: W/System.err(12326):    at org.jivesoftware.smack.ServerTrustManager.<init>(ServerTrustManager.java:70)
08-24 14:13:23.280: W/System.err(12326):    at org.jivesoftware.smack.XMPPConnection.proceedTLSReceived(XMPPConnection.java:871)
08-24 14:13:23.280: W/System.err(12326):    at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:221)
08-24 14:13:23.280: W/System.err(12326):    at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
08-24 14:13:23.280: W/System.err(12326):    at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
08-24 14:13:23.280: W/System.err(12326): Caused by: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found
08-24 14:13:23.300: W/System.err(12326):    at org.apache.harmony.security.fortress.Engine.notFound(Engine.java:177)
08-24 14:13:23.300: W/System.err(12326):    at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:151)
08-24 14:13:23.300: W/System.err(12326):    at java.security.KeyStore.getInstance(KeyStore.java:116)
08-24 14:13:23.300: W/System.err(12326):    ... 5 more
08-24 14:13:23.720: D/SMACK(12326): 02:13:23 PM SENT (736870032): <stream:stream to="chat.facebook.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
08-24 14:13:23.760: D/dalvikvm(12326): GC_FOR_ALLOC freed 197K, 5% free 9677K/10183K, paused 19ms
08-24 14:13:24.383: D/SMACK(12326): 02:13:24 PM RCV  (736870032): <?xml version="1.0"?><stream:stream id="D534089B" from="chat.facebook.com" version="1.0" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en">
08-24 14:13:24.390: D/SMACK(12326): 02:13:24 PM RCV  (736870032): <stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-FACEBOOK-PLATFORM</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms></stream:features>
08-24 14:13:24.390: I/System.out(12326): CONNECTED:true
08-24 14:13:24.430: D/SMACK(12326): 02:13:24 PM SENT (736870032): <auth mechanism="X-FACEBOOK-PLATFORM" xmlns="urn:ietf:params:xml:ns:xmpp-sasl"></auth>
08-24 14:13:24.798: D/SMACK(12326): 02:13:24 PM RCV  (736870032): <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dmVyc2lvbj0xJm1ldGhvZD1hdXRoLnhtcHBfbG9naW4mbm9uY2U9QjdFOTc2M0Q0Nzc2QTlDMTFBMjE0QTRCOTdFQzVEQjU=</challenge>
08-24 14:13:24.800: D/SMACK(12326): 02:13:24 PM SENT (736870032): <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bWV0aG9kPWF1dGgueG1wcF9sb2dpbiZub25jZT1CN0U5NzYzRDQ3NzZBOUMxMUEyMTRBNEI5N0VD
08-24 14:13:24.800: D/SMACK(12326): NURCNSZhY2Nlc3NfdG9rZW49Q0FBSkdJQlU5eDg4QkFHcXpRbnBNMXZFSW54YU11aWg2WkNLd0FX
08-24 14:13:24.800: D/SMACK(12326): NXpDVUs2U0lGSGZ5VDdMbFM2RGlYZThwdmVQTEhIZlpCdWpKNkJhdHRNT2pMZnQ3SG5zRktPOTRD
08-24 14:13:24.800: D/SMACK(12326): WVZEV3BGUHR5R1dSaXZJdkk0WkJJeEp5MXVUNHMxeXJvS0NTQXloTHlYblpDZjloZzhPc1FUNVRE
08-24 14:13:24.800: D/SMACK(12326): MFJjSzNJU1dEYW15SkJFRUptcWo5bzdZdXNtaEFaQ3BLNVpDWEhUaGRKSE56WFpCZlVBbmRkM3RI
08-24 14:13:24.800: D/SMACK(12326): ZmQzMkVXJmFwaV9rZXk9NjQwMDUzNTYyNjg5NDg3JmNhbGxfaWQ9MCZ2PTEuMA==</response>
08-24 14:13:25.208: D/SMACK(12326): 02:13:25 PM RCV  (736870032): <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
08-24 14:13:25.210: D/SMACK(12326): 02:13:25 PM SENT (736870032): <stream:stream to="chat.facebook.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
08-24 14:13:25.510: D/SMACK(12326): 02:13:25 PM RCV  (736870032): <?xml version="1.0"?><stream:stream id="90530E3B" from="chat.facebook.com" version="1.0" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en">
08-24 14:13:25.510: D/SMACK(12326): 02:13:25 PM RCV  (736870032): <stream:features><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></stream:features>
08-24 14:13:25.530: D/SMACK(12326): 02:13:25 PM SENT (736870032): <iq id="0imwt-0" type="set"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>Application</resource></bind></iq>
08-24 14:13:25.925: D/SMACK(12326): 02:13:25 PM RCV  (736870032): <iq id="0imwt-0" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>[email protected]/Application_a573c90d_4E4AD1661EFE6</jid></bind></iq>
08-24 14:13:25.925: D/SMACK(12326): 02:13:25 PM SENT (736870032): <iq id="0imwt-1" type="set"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>
08-24 14:13:26.330: D/SMACK(12326): 02:13:26 PM RCV  (736870032): <iq type="result" id="0imwt-1"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>
08-24 14:13:26.340: D/SMACK(12326): 02:13:26 PM SENT (736870032): <iq id="0imwt-2" type="get"><query xmlns="jabber:iq:roster" ></query></iq>
08-24 14:13:26.340: D/SMACK(12326): 02:13:26 PM SENT (736870032): <presence id="0imwt-3"></presence>
08-24 14:13:26.340: D/SMACK(12326): User logged (736870032): [email protected]@chat.facebook.com:5222/Application_a573c90d_4E4AD1661EFE6
08-24 14:13:26.340: I/System.out(12326): TLS:true
08-24 14:13:26.340: I/System.out(12326): Logged in:true

Here is my code for connection and authentication:

ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222);
             config.setDebuggerEnabled(true);
             config.setSASLAuthenticationEnabled(true);
            config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
           if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                config.setTruststoreType("AndroidCAStore");
                config.setTruststorePassword(null);
                config.setTruststorePath(null);
            } else {
                config.setTruststoreType("BKS");
                String path = System.getProperty("javax.net.ssl.trustStore");
                if (path == null)
                    path = System.getProperty("java.home") + File.separator + "etc"
                        + File.separator + "security" + File.separator
                        + "cacerts.bks";
                config.setTruststorePath(path);
            }
             xmpp = new XMPPConnection(config);
             SASLAuthentication.registerSASLMechanism("X-FACEBOOK-PLATFORM",SASLXFacebookPlatformMechanism.class);
             SASLAuthentication.supportSASLMechanism("X-FACEBOOK-PLATFORM", 0);
             System.out.println("PRE-CONNECTED");
             xmpp.connect();
             System.out.println("CONNECTED:"+xmpp.isConnected());
            Log.i("TOKEN", Session.getActiveSession().getAccessToken());

             xmpp.login("640053562689487", Session.getActiveSession().getAccessToken(),"Application");
2

3 Answers 3

2

I solved it. I just needed to grant xmpp_login permission.

3
  • ,i am also facing this issue since last one week,its showing "keystore jks implemention not found";i also added the sslcert too and could you tell me how u solved this problem
    – Karthick M
    Apr 1, 2014 at 11:27
  • I used your code,its working that Jks implementation not found issue solved,but i need to know some bit more how could i get all the friends lists or online friends alone,and one more thing i am not getting fb freinds list showing in logcat but dont know how its come like that,could you explain little more..
    – Karthick M
    Apr 1, 2014 at 13:20
  • You need to use rooster=xmpp.getRoster(),to get info about your friends. It is in XML format. Look at smack docs.
    – Kairat
    Apr 13, 2014 at 12:37
0

After login you need to set presence. You can do it as follows.

Presence presence = new Presence(Presence.Type.subscribe);
presence.setStatus("Online");
xmpp.sendPacket(presence);
2
  • what error are you getting now? Are you sending messages or just trying to receive the rooster? Aug 26, 2013 at 4:13
  • that's just the point that I am not getting any error. Connection, SASL authentication is ok, and server responds with success stanza: (08-26 15:16:58.770: D/SMACK(4168): 03:16:58 PM RCV (736995024): <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/> ). Then I open other FB account in PC browser in order to check my availibility. It is "unavailable"(offline). I tried to send messages from PC browser FB acc., but they are not delivered to my device.
    – Kairat
    Aug 26, 2013 at 9:31
0

Try adding one more line to presence.

presence.setMode(Presence.Mode.available);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.