Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
client
✓ const client = require('ari-client');
✗ import client from 'ari-client';
The library primarily uses CommonJS `require` syntax as demonstrated in its documentation and targets Node.js environments. Direct ESM `import` is not officially documented or supported for the main entry point in this version.
connect
✓ client.connect(url, username, password)
✗ import { connect } from 'ari-client';
`connect` is a method exposed by the default export `client`. It is not a named export. Ensure the `client` object is correctly obtained first.
ari.bridges
✓ const ari = await client.connect(url, username, password); ari.bridges.list();
✗ const bridges = require('ari-client').bridges;
Resource managers like `bridges`, `channels`, etc., are properties of the `ari` object returned by the `connect` function. They are not directly importable from the `ari-client` package itself.
Demonstrates connecting to Asterisk ARI, listing bridges, creating a new channel, and handling Stasis events using Promises.
const client = require('ari-client');
const url = process.env.ARI_URL ?? 'http://localhost:8088/ari';
const username = process.env.ARI_USERNAME ?? 'asterisk';
const password = process.env.ARI_PASSWORD ?? 'asterisk';
async function main() {
try {
console.log(`Connecting to ARI at ${url}...`);
const ari = await client.connect(url, username, password);
console.log('Successfully connected to ARI.');
// List all active bridges
console.log('Listing existing bridges...');
const bridges = await ari.bridges.list();
console.log(`Found ${bridges.length} bridge(s).`);
bridges.forEach(b => console.log(` Bridge ID: ${b.id}, Type: ${b.bridge_type}`));
// Create a new channel and listen for events
const channel = ari.Channel();
channel.on('StasisStart', (event, channelInstance) => {
console.log(`Channel ${channelInstance.id} entered Stasis application.`);
// Perform actions with the channel, e.g., answer, play media
channelInstance.answer()
.then(() => channelInstance.play({media: 'sound:hello-world'}))
.then(playback => console.log(`Playing sound: ${playback.id}`))
.catch(err => console.error(`Error playing sound: ${err.message}`));
});
channel.on('ChannelDtmfReceived', (event, channelInstance) => {
console.log(`DTMF received on channel ${channelInstance.id}: ${event.digit}`);
});
channel.on('StasisEnd', (event, channelInstance) => {
console.log(`Channel ${channelInstance.id} left Stasis application.`);
});
console.log('Originating a new channel...');
const originatedChannel = await channel.originate({
endpoint: 'PJSIP/1000',
app: 'my-stasis-app',
appArgs: 'dialed'
});
console.log(`Channel ${originatedChannel.id} originated. Waiting for events...`);
// Keep the process alive to receive events (in a real app, use a proper event loop)
// setTimeout(() => { console.log('Exiting after 60 seconds.'); process.exit(0); }, 60000);
} catch (err) {
console.error(`Failed to connect or interact with ARI: ${err.message}`);
process.exit(1);
}
}
main();
Errors
Common errors & fixes
TypeError: client.connect is not a function
Attempting to use `import client from 'ari-client'` or another ESM import style, but the package is primarily designed for CommonJS `require`.
fixUse `const client = require('ari-client');` to import the library in Node.js environments. Error: read ECONNRESET
The connection to the Asterisk ARI server was reset or refused. This often indicates incorrect URL, credentials, network issues, or ARI not being enabled/running on Asterisk.
fixVerify that Asterisk is running, ARI is enabled and configured correctly (`/etc/asterisk/ari.conf`), the URL (`ws://` or `wss://`), username, and password are all correct. Check firewall rules between your Node.js application and the Asterisk server.
UnhandledPromiseRejectionWarning: Error: bridge not found
An operation was attempted on a bridge ID that does not exist or is no longer active in Asterisk.
fixEnsure that the `bridgeId` being used is valid and corresponds to an active bridge. Use `ari.bridges.list()` to get a current list of bridges or verify bridge creation was successful.
Audit
Dependencies
swagger-jsrequiredCore dependency for generating the underlying API client from the Swagger/OpenAPI specification. `ari-client` builds its higher-level API on top of this.