Watch Aspire live streamsDocumentationEssayer Aspire

Get started with the Mosquitto integration

Ce contenu n’est pas encore disponible dans votre langue.

⭐ Community Toolkit

Eclipse Mosquitto is an MQTT message broker. The Community Toolkit integration runs Mosquitto in a container and exposes its MQTT endpoint to referenced Aspire resources.

  • An Aspire AppHost project
  • An MQTT client library for each application that connects to the broker

Install the 📦 CommunityToolkit.Aspire.Hosting.Mosquitto package in the AppHost:

Terminal
aspire add CommunityToolkit.Aspire.Hosting.Mosquitto

Create the broker resource and reference it from your application. See Set up Mosquitto in the AppHost for ports, storage, and broker configuration.

apphost.mts
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const mqtt = await builder.addMosquitto('mqtt');
const api = await builder.addProject('api', '../Api/Api.csproj');
await api.withReference(mqtt);
await api.waitFor(mqtt);
await builder.build().run();

The resource provides an MQTT connection URI to referencing resources. Its default configuration allows anonymous connections, so use a custom Mosquitto configuration before exposing the broker beyond a trusted development environment.