MqttControllerFramework 1.0.0-alpha.1

This is a prerelease version of MqttControllerFramework.
There is a newer version of this package available.
See the version list below for details.
dotnet add package MqttControllerFramework --version 1.0.0-alpha.1
                    
NuGet\Install-Package MqttControllerFramework -Version 1.0.0-alpha.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MqttControllerFramework" Version="1.0.0-alpha.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MqttControllerFramework" Version="1.0.0-alpha.1" />
                    
Directory.Packages.props
<PackageReference Include="MqttControllerFramework" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MqttControllerFramework --version 1.0.0-alpha.1
                    
#r "nuget: MqttControllerFramework, 1.0.0-alpha.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MqttControllerFramework@1.0.0-alpha.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MqttControllerFramework&version=1.0.0-alpha.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MqttControllerFramework&version=1.0.0-alpha.1&prerelease
                    
Install as a Cake Tool

MqttControllerFramework

A source-generated MQTT controller framework for .NET, built on top of MQTTnet.

Features

  • Attribute-driven routing — decorate methods with [MqttRoute("topic/+")] and the source generator wires them up automatically
  • Middleware pipelineIMqttMiddleware / MqttRequestDelegate (ASP.NET Core–style), with per-message DI scope and connection-scoped SessionItems for multi-tenancy
  • Authentication / Authorization — plug in IMqttAuthenticationProvider and IMqttAuthorizationProvider without touching domain types
  • Connection validation — optional IMqttConnectionValidator hook (ClientId format checks, IP bans, etc.)
  • Token-bucket rate limiting — per-client / per-topic, configurable via [TokenBucketRateLimit] attribute
  • Built-in statsIMqttBrokerStatsService exposes message counters, byte throughput, and per-topic summaries
  • TLS hot-swapHotSwappableServerCertProvider reloads PEM / PKCS#12 certificates without restart
  • Multi-targetnet8.0 and net10.0

Quick Start

// Program.cs
builder.Services
    .AddMqttServer(builder.Configuration)
    .WithControllers<GeneratedMqttControllerRegistration>()
    .WithAuthentication<MyAuthProvider>()
    .WithAuthorization<MyAuthzProvider>()
    .UseMiddleware<TenantMiddleware>()
    .WithRateLimiting();
// appsettings.json
"MqttSettings": {
  "EnableNonSsl": true,
  "NonSslPort": 1883,
  "EnableSsl": false
}
// Controller
[MqttController]
public class SensorsController
{
    [MqttRoute("sensors/{deviceId}/temperature")]
    public async Task OnTemperature(string deviceId, TemperaturePayload payload)
    {
        // handle message
    }
}

Middleware Example (multi-tenancy)

public class TenantMiddleware(ITenantContext tenant) : IMqttMiddleware
{
    public Task InvokeAsync(MqttMessageContext ctx, MqttRequestDelegate next)
    {
        if (ctx.SessionItems["tenantId"] is string tid)
            tenant.SetTenant(tid);
        return next(ctx);
    }
}

SessionItems is populated once during IMqttConnectionValidator.ValidateAsync and persists for the lifetime of the TCP connection, making it ideal for tenant or user resolution.

Status

Alpha — API may change before 1.0. Not recommended for production.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 40 6/6/2026
1.0.0-alpha.4 38 6/6/2026
1.0.0-alpha.2 36 6/6/2026
1.0.0-alpha.1 42 6/6/2026