MQTT

The MQTT is a lightweight messaging protocol, optimized for high-latency.

Installation

Before we start, we have to install required package:


$ npm i --save mqtt

Overview

In order to switch to MQTT transporter, we need to modify an options object passed to the createMicroservice() method.

main.ts
JS TS
TypeScript

const app = await NestFactory.createMicroservice(ApplicationModule, {
  transport: Transport.MQTT,
  options: {
    host: 'localhost',
    port: 1883,
  },
});

Options

There are a bunch of available options that determine a transporter behavior. They are well-described here.

  • MQTT
  • Installation
  • Overview
  • Options

Support us

Nest is an MIT-licensed open source project. It can grow thanks to the support by these awesome people. If you'd like to join them, please read more here.

Principal Sponsor

Sponsors / Backers