This health check add-on checks the state of a Mqtt broker. The NuGet can be found here.
The AddMqtt()
method adds a new health check with a specified name and the implementation of type IHealthCheck
. This is a custom class that implements IHealthCheck
, which takes either a IMqttClient or a IManagedMqttClient client a constructor parameter. Besides the client it also takes either a IMqttClientOptions or a IManagedMqttClientOptions parameter. This executes a simple query to check if the connection to the Mqtt broker is successful. It returns HealthCheckResult.Healthy()
if the query was executed successfully and a FailureStatus
with the actual exception when it fails.
- Check if connection to broker can be set up
- Mqtt managed client
- Mqtt unmanaged client
- Ping the broker if the connection is setup
Configure the services and add mqtt Health Check this way:
services
.AddHealthChecksUI()
.AddInMemoryStorage()
.Services
.AddHealthChecks()
.AddMqtt(client, managedClient);
Besides the actual implementation this repo also holds an example project that can be used as a playground and test out the application. Do note that you need to provide your own Mqtt server to test against.
This package makes use of the Semantic Versioning.
Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards compatible manner, and
- PATCH version when you make backwards compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
Version information.
- Updated nugets to the latest.
- Added protocol version information when the health is OK.
None.
First version
None.
- Support for MQTT unmanaged client
- Support for MQTT managed client
None.
This project is distributed under the Apache license version 2.0 (see the LICENSE file in the project root).
By submitting a pull request to this project, you agree to license your contribution under the Apache license version 2.0 to this project.