Registry / database / aedes-persistence-redis

aedes-persistence-redis

JSON →
library11.2.2jsnpmunverified

Redis-backed persistence plugin for the Aedes MQTT broker. Currently at v11.2.2 (stable, updated ~2024). Release cadence is irregular with frequent minor bumps. Key differentiators: supports Redis clusters, offline message TTL, configurable max session delivery, and uses ioredis internally. Compatible with Node.js >=20. ESM-only since v11. Breaks in v4 changed subscription key schema; see UPGRADE.md.

npm install aedes-persistence-redis
INSTALL
IMPORT
SIG · AEDES-PERSISTENCE-
A
aedes-persistence-redis
databasejavascriptv11.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

aedesPersistenceRedis
import aedesPersistenceRedis from 'aedes-persistence-redis'
const aedesPersistenceRedis = require('aedes-persistence-redis')
ESM-only since v11; named default export.
createPersistence
import { createPersistence } from 'aedes-persistence-redis'
Named export available as alternative; not documented above but exists in source.

Create an Aedes MQTT broker with Redis persistence, listen on port 1883.

import aedes from 'aedes' import aedesPersistenceRedis from 'aedes-persistence-redis' const persistence = aedesPersistenceRedis({ host: process.env.REDIS_HOST ?? 'localhost', port: Number(process.env.REDIS_PORT) || 6379, password: process.env.REDIS_PASS ?? '' }) const broker = aedes({ persistence }) broker.on('client', (client) => { console.log(`Client connected: ${client.id}`) }) const server = require('net').createServer(broker.handle) server.listen(1883, () => { console.log('MQTT broker running on port 1883') })
Debug
Known issues
breakingv4 changed the subscriptions key schema; old data not compatible
fix
Migrate or clear Redis data before upgrading to v4+; see PR #31.
affects: >=4.0.0 <11.0.0
deprecatedv11 drops CommonJS support; require() will fail
fix
Use ESM imports: import aedesPersistenceRedis from 'aedes-persistence-redis'
affects: >=11.0.0
gotchaCreates two Redis connections by default; might exhaust connection limits
fix
Pass a single external connection with conn option to control connections.
affects: >=1.0.0
gotchaPacket TTL option expects seconds, not milliseconds
fix
Ensure packetTTL returns seconds as Number.
affects: >=1.0.0
breakingNode.js >=20 required since v11; no longer supports older versions
fix
Upgrade Node.js to >=20.
affects: >=11.0.0
Errors
Common errors & fixes
Error: Cannot find module 'aedes-persistence-redis'
Missing npm install or wrong import path.
fix
Run npm install aedes-persistence-redis aedes
TypeError: aedesPersistenceRedis is not a function
Using require() instead of default import in ESM-only version.
fix
Use import aedesPersistenceRedis from 'aedes-persistence-redis' or switch to dynamic import.
ReplyError: MOVED ...
Attempting to connect to a Redis cluster without cluster option.
fix
Pass cluster: true or an array of cluster nodes as the first argument.
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server is not running or wrong host/port.
fix
Start Redis server on localhost:6379 or set REDIS_HOST and REDIS_PORT environment variables.
Upgrade
Version history
11.2.2latest on npm
Audit
Dependencies
aedesrequiredPeer dependency - persistence is a plugin for Aedes broker
Agent activity
38 hits · last 30 days
node
32
OpenAI (training)
1
Resources
aedes-persistence-redis — npm install aedes-persistence-redis · libregistry