Aedes Server Factory

0.2.1 · active · verified Tue Apr 21

aedes-server-factory is a utility library designed to simplify the creation and configuration of various server types for the Aedes MQTT broker. It currently supports TCP, HTTP, HTTP2, WebSockets (WS), and PROXY decoders, with ongoing work for TLS, HTTPS, and WSS. The latest stable version is 0.2.1, with releases happening infrequently, often driven by bug fixes or minor feature enhancements related to server handling. Its primary differentiator is providing a consolidated API to instantiate and bind Aedes to different network protocols and server technologies, abstracting away the boilerplate involved in connecting an MQTT broker to diverse client interfaces. It offers flexible options for secure connections and proxy support.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates creating both a default TCP MQTT server and a WebSocket server using an underlying HTTP server with aedes-server-factory.

import Aedes from 'aedes';
import { createServer } from 'aedes-server-factory';
import { createServer as createHttpServer } from 'http';

const aedes = Aedes();

// Create a basic TCP MQTT server
const tcpServer = createServer(aedes);
tcpServer.listen(1883, () => {
  console.log('Aedes TCP server listening on port 1883');
});

// Create an HTTP server and bind it for WebSockets
const httpServer = createHttpServer();
const wsServer = createServer(aedes, { ws: true, http: httpServer });

httpServer.listen(8080, () => {
  console.log('Aedes HTTP/WS server listening on port 8080');
});

// Handle cleanup on process exit
process.on('SIGTERM', () => {
  console.log('Shutting down Aedes servers...');
  tcpServer.close(() => console.log('TCP server closed.'));
  wsServer.close(() => console.log('HTTP/WS server closed.'));
  aedes.close(() => console.log('Aedes broker closed.'));
});

view raw JSON →