Registry / devops / aedes-cli

aedes-cli

JSON →
library1.0.2jsnpmunverified

aedes-cli provides a command-line interface (CLI) for running an Aedes MQTT broker instance. It simplifies the deployment and configuration of an Aedes broker, allowing users to quickly set up an MQTT server with various options for host, port, protocols (TCP, TLS, WS, WSS), authentication, authorization, and persistence. The current stable version is 1.0.2. Releases are generally driven by updates to the underlying Aedes library or dependency bumps, with a focus on stability and ease of use for CLI operations. Its key differentiator is offering a batteries-included CLI wrapper around the highly customizable Aedes library, abstracting away much of the programmatic setup for common use cases.

npm install aedes-cli
INSTALL
IMPORT
SIG · AEDES-CLI
A
aedes-cli
devopsjavascriptv1.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

start
import { start } from 'aedes-cli';
const { start } = require('aedes-cli');
Since v1.0.0, the package primarily uses ESM named exports for programmatic usage. While CommonJS `require` might work for the main CLI entry point, `start` is specifically exported as a named function.
createBroker
import { createBroker } from 'aedes-cli';
import Aedes from 'aedes-cli'; Aedes.createBroker();
For directly creating an Aedes broker instance programmatically via the CLI package's helper, use the named export `createBroker`. This is distinct from importing `Aedes` directly from the `aedes` package.
default
import aedesCli from 'aedes-cli/start';
import aedesCli from 'aedes-cli';
To run the CLI programmatically as if it were executed from the terminal, you might need to import a specific entry point like `aedes-cli/start`. Direct default import from 'aedes-cli' is not typically for programmatic execution of the CLI itself.

This code snippet demonstrates how to programmatically start the Aedes MQTT broker using `aedes-cli` with basic TCP and WebSockets protocols, and log connection events.

import { start } from 'aedes-cli'; import { fileURLToPath } from 'url'; import path from 'path'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); async function runBroker() { try { const options = { port: 1883, host: '0.0.0.0', protos: ['tcp', 'ws'], // Example for persistence - requires aedes-persistence-mongodb or similar // persistence: path.join(__dirname, 'my-persistence-plugin.js'), // Example for authorization // credentials: path.join(__dirname, 'credentials.json'), // authorizePublish: 'devices/+/data', // authorizeSubscribe: 'devices/#', }; const server = await start(options); server.on('ready', () => { console.log('Aedes MQTT Broker started successfully on port 1883 and host 0.0.0.0'); }); server.on('client', (client) => { console.log(`Client connected: ${client.id}`); }); server.on('clientDisconnect', (client) => { console.log(`Client disconnected: ${client.id}`); }); server.on('error', (err) => { console.error('Broker error:', err.message); }); } catch (error) { console.error('Failed to start Aedes CLI broker:', error); process.exit(1); } } runBroker();
aedes --version
Debug
Known issues
breakingWhile `aedes-cli` v1.0.0 stated 'no breaking changes to the aedes-cli API', it significantly updated its internal dependencies, including `aedes` to v1.0.0 and `yargs` to v18. Users relying on specific versions of underlying dependencies or expecting CommonJS patterns for programmatic imports may encounter issues. Ensure your environment supports ESM for programmatic usage.
fix
For programmatic usage, switch to ES Module import syntax (e.g., `import { start } from 'aedes-cli';`). Review `yargs` v18 documentation if you're interacting with its API directly within the CLI's programmatic capabilities.
affects: >=1.0.0
gotchaWhen using `aedes-cli` programmatically, the `start` function returns an Aedes server instance. It's crucial to handle errors on this server instance (e.g., `server.on('error', ...)`) as unhandled promise rejections or server errors can cause the process to exit unexpectedly. Prior versions had a 'blind catch' which was removed in 1.0.1, making error handling more explicit.
fix
Attach an error listener to the returned server object: `server.on('error', (err) => { console.error('Broker error:', err); });` to prevent unexpected crashes.
affects: >=1.0.1
gotchaDefault host for `aedes-cli` is `127.0.0.1`. If you're running it in a Docker container or want it accessible from other machines, you must explicitly set the host to `0.0.0.0`.
fix
Use the `--host 0.0.0.0` command-line option, or set `host: '0.0.0.0'` when starting programmatically. For Docker, this is often necessary in your `docker run` command or `docker-compose.yml`.
affects: <=1.0.2
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/aedes-cli/index.js from .../my-app.js not supported.
Attempting to `require()` aedes-cli programmatically in a CommonJS context when the library or its dependencies are now primarily ES Modules.
fix
Convert your project or the specific file to use ES Modules (`.mjs` extension or `"type": "module"` in `package.json`) and use `import { start } from 'aedes-cli';`.
Error: listen EADDRINUSE: address already in use 127.0.0.1:1883
Another process is already listening on the specified port (1883 by default).
fix
Stop the conflicting process, or specify a different port for aedes-cli using the `--port <new_port>` command-line option or `{ port: <new_port> }` in programmatic options.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
aedesrequiredCore MQTT broker functionality, aedes-cli wraps this library.
yargsrequiredUsed for parsing command-line arguments.
Agent activity
45 hits · last 30 days
node
38
OpenAI (training)
2
Resources