GCM连接错误

时间:2014-04-09 05:28:45

标签: java android xmpp google-cloud-messaging smack

我正在尝试使用XMPP(CCS)实现gcm服务器应用程序,我无法连接到谷歌服务器。 我正在尝试http://developer.android.com/google/gcm/ccs.html

中的示例代码

当我尝试连接时

ccsClient.connect(userName, password); 

我收到以下错误

gcm.googleapis.com:5235 Exception: XMPPError connecting to gcm.googleapis.com:5235.; : remote-server-error(502)
  -- caused by: XMPPError connecting to gcm.googleapis.com:5235.: remote-server-error(502) XMPPError connecting to gcm.googleapis.com:5235.
  -- caused by: java.net.ConnectException: Connection timed out: connect
    at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:592)
    at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1010)
    at SmackCcsClient.connect(SmackCcsClient.java:249)
    at Sample.main(Sample.java:342)
Nested Exception: 
XMPPError connecting to gcm.googleapis.com:5235.: remote-server-error(502) XMPPError connecting to gcm.googleapis.com:5235.
  -- caused by: java.net.ConnectException: Connection timed out: connect
    at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:565)
    at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1010)
    at SmackCcsClient.connect(SmackCcsClient.java:249)
    at Sample.main(Sample.java:342)
Nested Exception: 
java.net.ConnectException: Connection timed out: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknown Source)
    at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:557)
    at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1010)
    at SmackCcsClient.connect(SmackCcsClient.java:249)
    at Sample.main(Sample.java:342)
Exception in thread "main" java.lang.NoClassDefFoundError: SmackCcsClient$GcmPacketExtension
    at SmackCcsClient.send(SmackCcsClient.java:130)
    at Sample.main(Sample.java:357)
Caused by: java.lang.ClassNotFoundException: SmackCcsClient$GcmPacketExtension
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 2 more

我使用服务器密钥作为API密钥(密码) 和用户名=&#34;项目编号&#34; +&#34; @ gcm.googleapis.com&#34;

我的项目已列入上传消息列表的白名单 被认为关闭的港口在我的工作场所开放。 5228,5229和5230为我的IP。 我应该用哪个来打开端口?公共IP还是另一个?

可能是什么问题? 请帮我解决这个问题!提前致谢

1 个答案:

答案 0 :(得分:1)

您可以尝试从命令行 - 例如 “telnet gcm.googleapis.com 5235”

如果您看到“已连接到gcm.l.google.com” - 您的防火墙就很好。

CCS(第三方服务器使用的XMPP端点)正在使用端口5235 - 连接到GCM的android / chrome设备需要5228,5229个端口。

AFAIK 5230不是我们的端口之一,不知道你是怎么做到的。