Search code examples
androidxmlsmackfirebase-cloud-messagingxmlpullparser

Exceptions generated inside protected classes of Smack library


I am trying to establish a connection with Smack to Firebase Cloud Messaging CCS. I am having problems with the following protected Smack Interfaces. I dont know exactly why are these interfaces being called for?

See below how I establish my configuration builder object and my connection:

configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setServiceName("192.168.1.74").setHost("fcm-  xmpp.googleapis.com").setUsernameAndPassword(s1, s2)              .setPort(5236).setSendPresence(false).setCompressionEnabled(false).setCustomSSLContext(contexty)
other_connection = new XMPPTCPConnection(configBuilder.build());
//other_connection object is an AbstractXMPPConnection object

The android/smack code tries to connect but fails to do so. Here are the exceptions: Do note that my SSlcontext object has been initialized with keymanagerfactory that contains a key store who holds valid certificates validated by a certificate authority.

Exceptions:

**** Verification of void org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.<init>(org.jivesoftware.smack.tcp.XMPPTCPConnection) took 135.634ms*
07-29 03:30:14.211 3346-3408/rarigames.answerme V/RenderScript: 0xa172ca00 Launching thread(s), CPUs 2
07-29 03:30:39.281 3346-3548/rarigames.answerme D/ricky: Unable to connect or login to FCM CCS. org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 25000ms (~25s). Used filter: No filter used or filter was 'null'.
07-29 03:30:39.284 3346-3557/rarigames.answerme W/AbstractXMPPConnection: Connection closed with error
                                                                      org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT ��F@1:8 in java.io.BufferedReader@2c985591) 
                                                                          at org.kxml2.io.KXmlParser.next(KXmlParser.java:432)
                                                                          at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
                                                                          at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1169)
                                                                          at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:948)
                                                                          at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:963)
                                                                          at java.lang.Thread.run(Thread.java:818)

As you can see the Smack classes that are giving problems are: protected class XMPPTCPConnection.PacketReader and protected class XMPPTCPConnection.PacketWriter What is the Bufferedreader mentioned in the exception trying to read? An XML reply from FCM CCS? Should I authenticate this connection before trying to connect? Is that what is going on here that when I try to connect without authenticating the connection object is trying to authenticate itself and the XML packets are being sent to these protected classes of Smack library? How can I get these XML documents that are being possibly sent for authentication purposes, if they are really being sent by FCM CCS?

thanks for any advice or suggestion


Solution

  • Okay everyone:

    All I was missing here to get rid of the errors was an SSLsocket object. Since, I don't know much about sockets and machine to machine connections, I had no clue. After much reading, I realized I was missing this object. Errors are gone now that the connection can flow between my Android code and FCM CCS. so I just added this method call to my configBuilder object:

     .setSocketFactory(contexty.getSocketFactory());
    

    But, I am running into new errors that deal with SASLAuthentication using Smack. I will be posting a question on those errors soon. Seems I am getting closer to establishing a viable connection/login to FCM CCS.