Reputation: 631
I tried to connect to Cloud Connection Server of GCM using Smack API. My code:
ConnectionConfiguration config = new ConnectionConfiguration("gcm.googleapis.com","5235");
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);
config.setSocketFactory(SocketFactory.getDefault());
Connection conn = new XMPPConnection(config);
conn.connect();
conn.login(Config.GCM_SENDER_ID, Config.GCM_API_KEY);
However I got connection fail error and XMPPException error. Any ideas?
Upvotes: 0
Views: 1015
Reputation: 33413
According to the CCS documentation:
CCS requires a Transport Layer Security (TLS) connection. That means the XMPP client must initiate a TLS connection. For example in smack, you would call setSocketFactory(SSLSocketFactory), similar to “old style SSL” XMPP connections and https.
Therefore use the following in your code:
config.setSocketFactory(SSLSocketFactory.getDefault())
Upvotes: 2