gpt4 book ai didi

java - 使用 smack 库在 JAVA 中实现 GCM CCS (XMPP)。与 gcm.googleapis.com 的连接失败

转载 作者:行者123 更新时间:2023-11-30 11:21:15 27 4
gpt4 key购买 nike

我正在尝试使用 GCM 在 android 客户端和 java 中的服务器应用程序之间进行通信。我正在使用基于 XMPP 的 GCM,因为我需要异步的双向消息。

在我的客户端,1. Google Play 服务检查显示需要更新。

google play services is out of date. Requires 4242000 but found 3136130

API 级别 - 17,使用 AVD 和谷歌 API,Android 4.2.2Google Play 服务修订版 15我该如何解决这个问题?

但我可以成功注册设备。

在服务器端,我使用2.我用的是smack库3.4.1我使用了谷歌文档中的示例代码。我收到以下错误

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:247)
at SmackCcsClient.main(SmackCcsClient.java:341)
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:247)
at SmackCcsClient.main(SmackCcsClient.java:341)
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:247)
at SmackCcsClient.main(SmackCcsClient.java:341)
Exception in thread "main" java.lang.IllegalStateException: Not connected to server.
at org.jivesoftware.smack.XMPPConnection.sendPacket(XMPPConnection.java:483)
at SmackCcsClient.send(SmackCcsClient.java:131)
at SmackCcsClient.main(SmackCcsClient.java:356)

我已经签署了上游消息传递的表格。但批准仍在等待中。但是连接本身在这里失败了。我该如何解决这个问题。

请帮忙!提前致谢!!

最佳答案

ERROR CODE 502 表示连接服务器有问题,可能有多种原因,但一些常见问题是,

1 ) 防火墙问题 ----[正确配置你的防火墙]

2 ) 服务器内部错误----[重试后者]

关于java - 使用 smack 库在 JAVA 中实现 GCM CCS (XMPP)。与 gcm.googleapis.com 的连接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22325230/

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