Hello everyone.
I’m trying to convert a code of GCM server made in Smack 3.4.1 to 4.1.4.
This is the main part of 3.4.1 code:
config = new ConnectionConfiguration(GCM_SERVER, GCM_PORT);
-
config.setSecurityMode(SecurityMode.enabled);*
-
config.setReconnectionAllowed(true);*
-
config.setRosterLoadedAtLogin(false);*
-
config.setSendPresence(false);*
-
config.setSocketFactory(SSLSocketFactory.getDefault());*
-
// NOTE: Set to true to launch a window with information about packets*
-
// sent and received*
-
config.setDebuggerEnabled(true);*
-
// -Dsmack.debugEnabled=true*
-
XMPPConnection.DEBUG_ENABLED = true;*
-
connection = new XMPPConnection(config);*
-
connection.connect();*
And this is the code of 4.1.4:
XMPPTCPConnectionConfiguration config =
-
XMPPTCPConnectionConfiguration.builder()*
-
.setHost(GCM_SERVER)*
-
.setPort(GCM_PORT) *
-
.setServiceName(GCM_SERVER)*
-
.setCompressionEnabled(false)*
-
.setSecurityMode(SecurityMode.ifpossible)*
-
.setSendPresence(false) *
-
.setConnectTimeout(30000)*
-
.setDebuggerEnabled(true) *
-
.setSocketFactory(SSLSocketFactory.getDefault())*
-
*
-
.build();*
-
-
connection = new XMPPTCPConnection(config);*
-
*
-
//disable Roster as I don't think this is supported by GCM*
-
Roster roster = Roster.getInstanceFor(connection);*
-
roster.setRosterLoadedAtLogin(false);*
-
logger.info("Connecting...");*
-
connection.connect();*
connection*.login(senderId + "@gcm.googleapis.com" , apiKey);*
The problem is that i can’t get this new code to work, it returns me .
The Smack API is sending this in the login method:
QURnek16UTNORGMyTVRrd05VQm5ZMjB1WjI5dloyeGxZWEJwY3k1amIyME FRVWw2WVZONVEyVkdVbUptVTNobmVVcHBVbXQ2ZEVWeGFuTnhjbFpwVDBodWNXVnZXbEpO
I searched Google site for information, the login method should send something like that:
<auth mechanism=“PLAIN”
xmlns=“urn:ietf:params:xml:ns:xmpp-sasl”>MTI2MjAwMzQ3OTMzQHByb2plY3RzLmdjbS5hb
mFTeUIzcmNaTmtmbnFLZEZiOW1oekNCaVlwT1JEQTJKV1d0dw==
Looks like the auth type is wrong. How do i change that ?
Can anyone give me a help ?
Thanks.