jM2.me
jM2.me

Reputation: 3969

Can't connect to GCM using node-xmpp client

I am attempting to run gcm server using node-xmpp, but xmpp client does not seem to open at all and closes after timeout.

var xmpp = require('node-xmpp-client');

var options = {
  type: 'client',
  jid: '[email protected]',
  password: 'ApiKeyHere',
  port: 5235,
  host: 'gcm.googleapis.com',
  legacySSL: true,
  preferredSaslMechanism : 'PLAIN'
};

console.log("Creating XMPP Application");

var cl = new xmpp.Client(options);

cl.on('online', function()
{
    console.log("XMPP Online");
});

Rest of the code was omitted. In the console, I never get to see "XMPP Online". How do I check if xmpp is even connecting, and where it fails to open?

Upvotes: 2

Views: 1691

Answers (3)

Riplexus
Riplexus

Reputation: 340

I got the same problem and found out that the Connection.startStream() was never called, although the socket was opened successfully.

Here's my pull request: https://github.com/node-xmpp/node-xmpp-client/pull/61

Until it gets merged, you can use my fork, which should work for GCM: https://github.com/Riplexus/node-xmpp-client

Upvotes: 2

jM2.me
jM2.me

Reputation: 3969

I have given up the hope of using node-xmpp and game smack client a try. Sadly it did not work, but I did get an error saying my project is not whitelisted. When project is whitelisted, it can receive messages from android devices, which is exactly what I need and is the sole reason why I went straight to CCS (XMPP). Without the whitelist, it is not possible to use CCS (XMPP) for sending the messages to android devices. In order to use HTTP method, the project does not need to be whitelisted, but has a limitation to being able to send messages only. I have signed up upstream GCM but have yet to receive response.

https://services.google.com/fb/forms/gcm/

Upvotes: 0

guy_fawkes
guy_fawkes

Reputation: 965

I followed this from gcm google groups and it worked for me. And for timeouts you can try xmppClient.connection.socket.setTimeout(0) xmppClient.connection.socket.setKeepAlive(true, 10000) Don't forget to whitelist your server ip in google console.

Upvotes: 0

Related Questions