0
votes

I'm trying to connect to the Firebase Cloud Messaging Server (CCS) using xmpp protocol in Node.js. So far I was unsuccessful.

I'm using node-xmpp-client library and it gives me the following error:

{ [Error: connect ETIMEDOUT 64.233.191.188:5235]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '64.233.191.188',
  port: 5235 }

and here is my code:

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

var client = new Client({
  jid:      '<my sender id>@gcm.googleapis.com',
  password: '<my server key>',
  host:     'fcm-xmpp.googleapis.com',
  port:     5235
});

client.connection.socket.on('error', function (error) {
  console.log("socket error");
  console.error(error);
  process.exit(1);
});

client.on('online', function (data) {
  console.log('Connected as ' + data.jid.local + '@' + data.jid.domain + '/' + data.jid.resource);
});

client.on('error', function (err) {
  console.log("server error");
  console.error(err);
  process.exit(1);
});
1
I'm not sure about this, but maybe it's with your jid (gcm...) and host (fcm...). I think it should be same fcm? Can you try?AL.
@intj thanks for the comment, but it failed too...Jay
What about just using the sender id for your jid? Remove the @gcm.googleapis.com? I think I remember a similar post, but I'm not entirely sure.AL.
@intj thank you for the followup. but it did't work eitherJay
Hey @JamshidAsadzadeh How was it? Are you still experiencing this error? Can you also verify what type of API key you're using?AL.

1 Answers

0
votes

Try with Client.Client and add legacySSl and preferredSaslMechanism

const XMPP = require('node-xmpp-client');
this._client = new XMPP.Client({
        jid: `${config.id}@gcm.googleapis.com`,
        password: config.key,
        port: config.port,
        host: config.host,
        legacySSL: true,
        preferredSaslMechanism: 'PLAIN'
      });

This works for me