Google Cloud Messaging - 服务器连接

时间:2013-08-14 10:07:26

标签: java android smack google-cloud-messaging

我开始使用Google Cloud Messaging编写一些应用程序,但我遇到了服务器问题。我使用了Android Developer端的代码 - 使用Smack库的Java示例(我不会在这里上传代码,因为它很长):

GCM Cloud connection Server (XMPP)

我在Google Apis上启用了Google云消息传递,我更改了我的SENDER_ID,API KEY和Registration_ID,但是当我启动该程序时,我遇到了这样的错误:

    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));`

也许你知道我做错了什么?

1 个答案:

答案 0 :(得分:3)

好的我遇到了同样的问题,我通过寻找一些防火墙规则来修复它。
也许您可以尝试添加规则以从内部向gcm.googleapis.com授予访问权限。

PS:也许您必须指定IP而不是gcm.googleapis.com