Auto reconnect.

Included and enabled in @xmpp/component and @xmpp/client.

Supports Node.js and browsers.

reconnect will only be enabled once the entity goes online for the first time. Each reconnect will re-use the options provided to the entity start method.


npm install @xmpp/plugins


const reconnect = entity.plugin(require('@xmpp/plugins/reconnect'))

delay property

Property to set/get the delay in milliseconds between connection closed and reconnecting.

Default is 1000.

reconnect.delay // 1000
reconnect.delay = 2000

reconnecting event

Emitted each time a re-connection is attempted.

reconnect.on('reconnecting', () => {

reconnected event

Emitted each time a re-connection succeed.

reconnect.on('reconnected', () => {

error event

Emitted each time a re-connection fails.

reconnect.on('error', err => {
  console.error('reconnection error', err)