简体   繁体   中英

Google Cloud Messaging - server connection

I started to write some application using Google Cloud Messaging, but I have problem with the server. I used code from Android Developer side - Java sample using the Smack library (I will not upload code here, because it is quite long):

GCM Cloud connection Server (XMPP)

I have turn on Google Cloud Messaging on Google Apis and I changed my SENDER_ID, API KEY and Registration_ID, but when I start the program I have errors like this:

    gcm.googleapis.com:5235 Exception: XMPPError connecting to gcm.googleapis.com:5235.; : remote-server-error(502)
    at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:604)
        at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1026)
        at SmackCcsClient.connect(SmackCcsClient.java:248)
        at SmackCcsClient.main(SmackCcsClient.java:342)
    Exception in thread "main" java.lang.IllegalStateException: Not connected to server.
        at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:495)
        at SmackCcsClient.send(SmackCcsClient.java:132)
        at SmackCcsClient.main(SmackCcsClient.java:357)

SmackCcsClient.java:248 -> `connection.connect();`

SmackCcsClient.java:342 -> `ccsClient.connect(userName, password);`

SmackCcsClient.java:132 -> `connection.sendPacket(request);`

SmackCcsClient.java:357 -> `ccsClient.send(createJsonMessage(toRegId, messageId, payload, collapseKey,timeToLive, delayWhileIdle));`

Maybe you know what I done wrong?

Ok I encountered the same problem and I fixed it by looking for some firewall rules.
Maybe you can try to add a rule to grant access from inside to gcm.googleapis.com.

PS: Maybe you'll have to specify an IP instead of gcm.googleapis.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM