gpt4 book ai didi

java - GCM 连接错误

转载 作者:行者123 更新时间:2023-12-01 13:10:02 27 4
gpt4 key购买 nike

我正在尝试使用 XMPP(CCS) 实现 gcm 服务器应用程序,但无法连接到 google 服务器。我正在尝试 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

我使用服务器 key 作为 API key (密码)和用户名=“项目编号”+“@gcm.googleapis.com”

我的项目已列入上游消息传递白名单被认为关闭的端口在我的工作场所被打开。我的 IP 为 5228、5229 和 5230。我应该使用哪个 IP 来打开端口?公共(public) IP 还是其他 IP?

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

最佳答案

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

如果您看到“已连接到 gcm.l.google.com”,则表明您的防火墙正常。

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

AFAIK 5230 不是我们的端口之一,不确定您是如何获得它的。

关于java - GCM 连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22953528/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com