AnsweredAssumed Answered

GCM using smack library NoResponseException: No response received within reply timeout

Question asked by Santhosh on Jun 25, 2015
Latest reply on Jun 15, 2016 by Danilo Guimarães

I am new to gcm and I tried to connect to Cloud Connection Server(XMPP) of GCM using Smack API. It was alright at the start,

My code:

 

    uid = "123456789";

    apiKey = "A**************B";

    XMPPTCPConnectionConfiguration.Builder config;

    config.setSocketFactory(SSLSocketFactory.getDefault());

        config = XMPPTCPConnectionConfiguration.builder();

        config.setUsernameAndPassword(uid,apiKey);

        config.setServiceName("gcm.googleapis.com");

        config.setHost("gcm.googleapis.com");

        config.setPort(5235);

        config.setDebuggerEnabled(true);

        mConnection = new XMPPTCPConnection(config.build());

        mConnection.setPacketReplyTimeout(10000);

        try {

             mConnection.connect();

             mConnection.login();

            }

       catch (SmackException | IOException | XMPPException e) {

                System.out.println("Exception at SmackCcsClient.init()");

                e.printStackTrace();

            }

 

But I couldnt get past the initial handshaking process. At first I used some dummy random GCMIDs to test downstream messaging and it was showing up in the smack debug window but later on, the same code shows nothing after the following xml feed as **Raw sent packets**:

 

    <stream:stream xmlns='jabber:client' to='gcm.googleapis.com'  xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>

 

and i tried

 

    mConnection.login(uid+"@gcm.googleapis.com",apiKey);//even though i assume its next step of the handshake.

 

Console prints the following errors:

 

    org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 10000ms (~10s). Used filter: No filter used or filter was 'null'.

    at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackExceptio n.java:106)

    at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackExceptio n.java:85)

    at org.jivesoftware.smack.SynchronizationPoint.checkForResponse(SynchronizationPoi nt.java:253)

    at org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWait(Synchronizatio nPoint.java:146)

    at org.jivesoftware.smack.SynchronizationPoint.checkIfSuccessOrWaitOrThrow(Synchro nizationPoint.java:125)

    at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:837)

    at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.ja va:360)

    at psdc.gcm.SmackCcsClient.init(SmackCcsClient.java:64)

    at psdc.gcm.GCMServer.activate(GCMServer.java:44)

    at psdc.servlets.Mapper.selectIds(Mapper.java:191)

    at psdc.servlets.Mapper.doPost(Mapper.java:152)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil terChain.java:291)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain .java:206)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil terChain.java:239)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain .java:206)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java: 219)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java: 106)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.ja va:501)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve .java:610)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88 )

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)

    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processo r.java:1086)

    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractPr otocol.java:659)

    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http 11NioProtocol.java:223)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1 558)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:151 5)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java: 61)

    at java.lang.Thread.run(Unknown Source)

 

    Jun 25, 2015 5:36:18 PM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener

    WARNING: Connection closed with error

    java.io.EOFException: input contained no data

        at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:2965)

        at org.xmlpull.mxp1.MXParser.more(MXParser.java:3003)

        at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1409)

        at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1394)

        at org.xmlpull.mxp1.MXParser.next(MXParser.java:1092)

        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1151)

        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon nection.java:937)

        at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:952)

        at java.lang.Thread.run(Unknown Source)

 

 

Please help me to solve this as i am really stuck with this and nowhere to go.

Am using the SMACK 4.1.1

Outcomes