简体   繁体   English

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

[英]GCM CCS (XMPP) implementation in JAVA using smack library. Connection failed with gcm.googleapis.com

I am trying out GCM for communication between android client and a server application in java. 我正在尝试GCM在android客户端和java中的服务器应用程序之间进行通信。 I am using XMPP based GCM as i need asynchronous, bidirectional messages. 我正在使用基于XMPP的GCM,因为我需要异步的双向消息。

On my client side, 1. Google Play Service check showed that an update is required. 在我的客户端上,1. Google Play服务检查显示需要更新。

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

Api level- 17, Using AVD with google API, Android 4.2.2 Google play services Revision 15 How can i solve this? Api级别-17,将AVD与Google API结合使用,Android 4.2.2 Google Play服务修订版15我该如何解决?

But i can successfully register the device. 但是我可以成功注册该设备。

On Server side, i use 2. I am using smack library 3.4.1 i used the sample code in google docs. 在服务器端,我使用2。我正在使用smack库3.4.1,我在google docs中使用了示例代码。 I get the following error 我收到以下错误

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)

I have signed up the form for upstream messaging. 我已经签署了用于上游消息传递的表格。 but the approval is still pending. 但审批仍在进行中。 But the connection itself fails here. 但是连接本身在这里失败。 How can i solve this. 我该如何解决。

Please Help! 请帮忙! Thank you in advance!! 先感谢您!!

The ERROR CODE 502 implies that there is problem with connecting SERVER, There might be several reasons but some common problem are, ERROR CODE 502表示连接SERVER时出现问题,可能有多种原因,但是一些常见的问题是,

1 ) FIREWALL PROBLEM ----[configure properly your firewall] 1) FIREWALL PROBLEM ---- [正确配置防火墙]

2 ) Server internal error ----[retry latter] 2)服务器内部错误---- [重试后一]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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