GCM connection error

主宰稳场 提交于 2020-01-24 00:18:29

问题


I am trying out implementing gcm server application using XMPP(CCS) and i cant able to connect to the google servers. I am trying out the sample code from http://developer.android.com/google/gcm/ccs.html

when i try to connect

ccsClient.connect(userName, password); 

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: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

I am using server key for the API key(password) and username="project number"+"@gcm.googleapis.com"

My project is whitelisted for upstream messaging Ports considered to be closed are made open at my workplace. 5228, 5229, and 5230 for my IP. which Ip should i use to open up the ports? public Ip or the other one?

What could be the problem? Please help me resolve this! Thanks in advance


回答1:


Can you try from the command line - for example "telnet gcm.googleapis.com 5235"

If you see "Connected to gcm.l.google.com" - your firewall is good.

CCS ( the XMPP endpoint using by 3rd party servers ) is using port 5235 - the 5228, 5229 ports are needed for android/chrome devices connecting to GCM.

AFAIK 5230 is not one of our ports, not sure how you got it.



来源:https://stackoverflow.com/questions/22953528/gcm-connection-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!