RabbitMQ HTTP API Client
This library, `http-rabbitmq-manager`, is a Node.js client designed to interact with the RabbitMQ HTTP API. As of version 0.0.4, with its last commit over seven years ago, the package is considered abandoned and no longer actively maintained. It provides a programmatic interface for management and monitoring tasks such as retrieving cluster overview, listing nodes, connections, channels, consumers, and exchanges, and setting cluster definitions. A significant limitation is its official support for only RabbitMQ 3.x, while the current stable RabbitMQ version is 4.2.5. This means it may not be compatible with newer RabbitMQ installations or features. The library's functionality relies heavily on the RabbitMQ Management UI plugin being installed and enabled on the RabbitMQ server. The API uses traditional Node.js callback patterns for asynchronous operations, which differs from modern Promise-based or `async/await` paradigms. For current RabbitMQ monitoring, official documentation now recommends tools like Prometheus and Grafana over direct HTTP API scraping for long-term data collection.
Common errors
-
TypeError: require(...) is not a function
cause Attempting to call the main module export directly instead of accessing the `client` property.fixUse `const client = require('http-rabbitmq-manager').client({ /* config */ });` to correctly access the client factory. -
Error: connect ECONNREFUSED
cause The RabbitMQ server is not running, the Management UI plugin is not enabled, or the `host` or `port` configuration is incorrect.fixVerify RabbitMQ server status and ensure the `rabbitmq_management` plugin is enabled. Check that the configured `host` and `port` (default 15672) match your RabbitMQ management interface. -
401 Unauthorized (or similar HTTP status in error callback)
cause Incorrect `user` or `password` provided in the client configuration.fixDouble-check the username and password for a user with management permissions in your RabbitMQ instance. -
TypeError: client.overview is not a function
cause The `client` object was not correctly initialized, likely because the `.client()` method was not called or its return value wasn't assigned.fixEnsure the client is properly instantiated: `const client = require('http-rabbitmq-manager').client({ /* config */ });`. -
Error: Timeout of XXXXms exceeded (or similar timeout error)
cause The API request took longer than the configured `timeout` value, or the RabbitMQ HTTP API is experiencing high load or slowness.fixIncrease the `timeout` option in the client configuration if your network or RabbitMQ server response times are consistently high. Investigate RabbitMQ server performance if timeouts persist.
Warnings
- breaking This package officially supports only RabbitMQ 3.x versions. Modern RabbitMQ versions (e.g., 4.x, 3.12+) have significant changes, and this client may not be compatible or function correctly.
- gotcha The package is in version 0.0.4 and has seen no commits in over seven years, indicating it is abandoned. There will be no new features, bug fixes, or security updates. The API should be considered unstable.
- gotcha This library relies on the RabbitMQ Management UI plugin being installed and enabled on your RabbitMQ server. Without it, the HTTP API endpoints will not be available, and the client will fail to connect or retrieve data.
- gotcha The API exclusively uses Node.js callback patterns for asynchronous operations. This can lead to 'callback hell' in complex scenarios and is less ergonomic than modern Promise-based or `async/await` patterns.
- gotcha For long-term monitoring, alerting, and advanced visualization of RabbitMQ metrics, official RabbitMQ documentation recommends using Prometheus and Grafana, as the HTTP API is primarily for basic observability. Relying solely on this client for comprehensive monitoring might be insufficient.
Install
-
npm install http-rabbitmq-manager -
yarn add http-rabbitmq-manager -
pnpm add http-rabbitmq-manager
Imports
- client
const managerClient = require('http-rabbitmq-manager')({ /* config */ });const managerClient = require('http-rabbitmq-manager').client({ /* config */ });
Quickstart
const client = require('http-rabbitmq-manager').client({
host: process.env.RABBITMQ_HOST ?? 'localhost',
port: parseInt(process.env.RABBITMQ_MANAGEMENT_PORT ?? '15672'),
timeout: parseInt(process.env.RABBITMQ_TIMEOUT ?? '25000'),
user: process.env.RABBITMQ_USER ?? 'guest',
password: process.env.RABBITMQ_PASSWORD ?? 'guest'
});
console.log('Fetching RabbitMQ cluster overview...');
client.overview(function (err, res) {
if (err) {
console.error('Error fetching overview:', err.message);
return;
}
console.log('Overview:', JSON.stringify(res, null, 2));
console.log('\nListing all nodes...');
client.listNodes(function (err, nodes) {
if (err) {
console.error('Error listing nodes:', err.message);
return;
}
console.log('Nodes:', JSON.stringify(nodes, null, 2));
console.log('\nListing all connections...');
client.listConnections(function (err, connections) {
if (err) {
console.error('Error listing connections:', err.message);
return;
}
console.log('Connections:', JSON.stringify(connections, null, 2));
});
});
});