An XMPP client library built using nodejs. Also runs in the browser thanks to browserify.

var Client = require('node-xmpp-client')
var client = new Client(...parameters...)

Parameters

  • jid [String]: The jid of the user you wish to log in as. If no host parameter provided an SRV lookup will be performed on the domain (where possible).
  • password [String]: Password to be used for login
  • host [String]: The host where the the XMPP server is located
  • preferredSaslMechanism [String]: The preferred SASL mechanism to use for authentication
  • bosh [Object]: An object to specify BOSH options
    • url [String]: The BOSH URL endpoint to use (used in preference to a socket if provided)
    • wait [Int]: See wait attribute
  • websocket [Object]: An object to specify WebSocket options
    • url [String]: The WebSocket URL endpoint to use (used in preference to a socket and BOSH endpoint if provided)
  • register [Boolean]: Create a new account on the server
  • port [Int]: Port number to use for socket connection
  • reconnect [Boolean]: Reconnect on disconnection
  • legacySSL [Boolean]: Connect to the legacy SSL port (5223) - requires at least the host to be specified
  • credentials [Boolean]: TLS or SSL key and certificate credentials
  • actAs [String]: if admin user act on behalf of another user
  • disallowTLS [Boolean]: Prevent upgrading of the connection to a secure one using TLS
  • oauth2_token [String]: OAuth2 token e.g. used for logging into google talk
  • oauth2_auth [String]: OAuth2 namespace e.g. used for logging into google talk
  • api_key [String]: For logging into Facebook XMPP account
  • access_token [String]: For logging into Facebook XMPP account
  • wait [String]: The HTTP-BIND wait value (in seconds). This is the time the server will wait before returning an empty result for a request. Default is 10 seconds.

Basic Example

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

var client = new Client({
    jid: 'user@example.com',
    password: 'password'
})

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

client.on('stanza', function(stanza) {
    console.log('Incoming stanza: ', stanza.toString())
})

Closing a connection

client.end()

In the browser

node-xmpp-client can be run in the browser thanks to browserify. A latest bundled release should be found with each release.

When using node-xmpp-client within the browser you must specify either a boshURL or a websocketsURL in order to make the connection.

Manually builing

In order to manually build the bundle install the developer dependencies, e.g.

npm i . --development

Then run grunt browserify the output file will then be generated for you.