2

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: 'fake-project-123@gcm.googleapis.com',
  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?

peak
  • 105,803
  • 17
  • 152
  • 177
jM2.me
  • 3,839
  • 12
  • 44
  • 58

3 Answers3

2

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

Riplexus
  • 340
  • 1
  • 10
  • Very nice! I tried to debug the source of issue, but since I am not much familiar with node there wasn't much luck. Glad to see that issue is resolved. – jM2.me Jul 31 '14 at 06:31
0

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.

guy_fawkes
  • 947
  • 8
  • 31
  • That is the sample I started with. Figured I might have missed something, so I quickly copy&pasted and edited it. The issue persists. Setting timeout doesn't seem to do anything. The api key I am using is allowed on all IPs 0.0.0.0/0 The code that is supposed to run when client is online does not get executed at all. – jM2.me Mar 22 '14 at 03:26
  • Can we connect to ccs servers from localhost while development ? Not using a static ip ? – guy_fawkes Mar 22 '14 at 03:39
  • I believe so. On the "Getting Started" page it is noted "For testing purposes, you can use 0.0.0.0/0" for the step where server IP for the API key has to be entered. – jM2.me Mar 22 '14 at 04:09
  • @jM2.me localhost can be used to connect to ccs. It works. Can you please look at this http://stackoverflow.com/questions/22606366/send-downstream-message-to-google-ccs-with-node-js – guy_fawkes Mar 24 '14 at 11:36
0

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/

jM2.me
  • 3,839
  • 12
  • 44
  • 58