GCM CCS (XMPP) implementation in JAVA using smack

2019-04-13 17:33发布

I am trying out GCM for communication between android client and a server application in java. I am using XMPP based GCM as i need asynchronous, bidirectional messages.

On my client side, 1. Google Play Service check showed that an update is required.

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?

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. 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!!

1条回答
男人必须洒脱
2楼-- · 2019-04-13 18:14

The ERROR CODE 502 implies that there is problem with connecting SERVER, There might be several reasons but some common problem are,

1 ) FIREWALL PROBLEM ----[configure properly your firewall]

2 ) Server internal error ----[retry latter]

查看更多
登录 后发表回答