2

I am using node-xmpp library to communicate with ejabberd server installed on ubuntu.

I have the following script to register and perform actions in the server..

var xmpp          = require("node-xmpp");
var c2s = new xmpp.C2SServer({
    port: 5223,
    domain: 'domain.com'
});

c2s.on('connect', function(client) {

    console.log('connect ??? ++++++++');

    c2s.on('register', function(opts, cb) {
        console.log('REGISTER')
        cb(true)
    })
    client.on('authenticate', function(opts, cb) {
        console.log('AUTH' + opts.jid + ' -> ' +opts.password)
        cb(null) // cb(false)
    })

    client.on('disconnect', function() {
        console.log('DISCONNECT')
    })

});

I am able to see the connect message in the server. But its not invoking the register event.

However i have another ejabberd instance in 5222 port which is working fine for registration from Audium XMPP Client.

niksmac
  • 2,667
  • 3
  • 34
  • 50

2 Answers2

1

Just change in the Register event cb(true) with cb(false)..and should work now :)

Worker1
  • 195
  • 10
0

xmpp.C2SServer is a building block to use if you are writing your own server.

If you want to connect to an existing XMPP server, you need to use:

import xmpp from 'node-xmpp-client'
const client = new xmpp.Client( ... )

Then follow XEP-0077 to register an account on the server.

smokku
  • 1,256
  • 13
  • 22