Skip to content

Commit 332109b

Browse files
authored
New Automatic Reconnect Ability (#184)
1 parent f51e332 commit 332109b

17 files changed

+2252
-2338
lines changed

Documentation/docs/intro.md

+24-6
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,33 @@ sidebar_position: 10
44

55
# The MQTT Client
66

7-
* **Easy-to-Install**: Available as a Nuget package.
8-
* **Opensource**: No blackbox code. Only trusted, tested and reviewed opensource code.
7+
### 💽 Installation & Compatibility
8+
* **Easy-to-Install**: Available as a [Nuget package](https://www.nuget.org/packages/HiveMQtt).
9+
* **Globally Compatible**: Built to be a fully compliant MQTT 5.0 client compatible with all modern MQTT brokers.
10+
* **Multi-Targeted**: Supports .NET 6.0, 7.0 & 8.0
11+
12+
### 🚀 Features
13+
* **MQTT 5.0 Support**: Fully compliant with the latest [MQTT 5.0 specification](https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html), ensuring compatibility with modern MQTT brokers.
14+
* **Back Pressure Management**: Automatically manages back pressure to prevent overwhelming the broker (or client), ensuring reliable and efficient communication.
15+
* **Asynchronous Design**: Designed for high-performance and low-latency communication, allowing your application to process multiple messages concurrently.
16+
* **Extensive Event System**: Hook into all parts of the client down to the packet level with [built in events](https://hivemq.github.io/hivemq-mqtt-client-dotnet/docs/events).
17+
* **Global and Per-Subscription Message Handling**: Use multiple targeted handlers for more targeted and specialized message processing.
18+
* **Full Last Will & Testament Support**: Reliable message delivery and notification of client disconnections.
19+
* **Secure Client Identification**: Full support for [X.509 client certificates](https://hivemq.github.io/hivemq-mqtt-client-dotnet/docs/how-to/client-certificates) and TLS connections.
20+
* **Observable**: Configure up to [TRACE level logging](https://hivemq.github.io/hivemq-mqtt-client-dotnet/docs/how-to/debug) for package internals.
21+
* **Fast**: Optimized & benchmarked. See the benchmark results [here](https://github.com/hivemq/hivemq-mqtt-client-dotnet/blob/main/Benchmarks/ClientBenchmarkApp/README.md).
22+
23+
### 🏝️ Ease of Use
924
* **Easy to Use**: Smart defaults, excellent interfaces and intelligent automation makes implementing a breeze.
10-
* **MQTT v5.0 compatible**: Backported versions 3.1.1 & 3.0 coming soon!
11-
* **Extensive Event System**: Hook into all parts of the client down to the packet level with [built in events](https://github.com/hivemq/hivemq-mqtt-client-dotnet/blob/main/Documentation/Events.md).
12-
* **Globally Compatible**: Built to be a fully compliant client compatible with all reputable MQTT brokers.
25+
* **Easy Integration**: Simple and intuitive API makes it easy to integrate with your .NET applications.
26+
27+
### 🛟 Maintenance and Support
1328
* **Actively Maintained**: Built by the MQTT professionals that built HiveMQ (and do this for a living).
14-
* **Extensively Documented**: What good is it without excellent documentation?
1529
* **Supported**: Contact us anytime in [this repository](https://github.com/hivemq/hivemq-mqtt-client-dotnet/issues), in the [community forum](https://community.hivemq.com) or [through support](https://www.hivemq.com/support/).
30+
* **Extensively Documented**: What good is it without [excellent documentation](https://hivemq.github.io/hivemq-mqtt-client-dotnet/)?
31+
32+
### 🐧 Opensource
33+
* **Opensource**: No blackbox code. Only trusted, tested and reviewed opensource code.
1634

1735
## What is this?
1836

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Automatic Reconnect
2+
3+
The HiveMQtt MQTT library provides an automatic reconnect functionality that allows the client to automatically reconnect to the MQTT broker in case of a disconnection. This feature is disabled by default.
4+
5+
# Example
6+
7+
```csharp
8+
var options = new HiveMQClientOptionsBuilder()
9+
.WithAutomaticReconnect(true)
10+
.Build();
11+
12+
// Create a new client with the configured options
13+
var client = new HiveMQttClient(options);
14+
```
15+
16+
# Backoff Strategy
17+
18+
The automatic reconnect functionality uses a backoff strategy to attempt to reconnect to the MQTT broker periodically until success. The backoff strategy starts with a delay of 5 seconds and doubles the delay with each failed attempt, up to a maximum of 1 minute.
19+
20+
# Maximum Attempts
21+
22+
The backoff strategy will attempt to reconnect a maximum of once per minute. The client will attempt to reconnect indefinitely until successful.
23+
24+
# Summary
25+
26+
The automatic reconnect functionality a convenient way to handle disconnections from the MQTT broker. Users can also use the `OnConnect` event handler to add custom logic when the client successfully reconnects to the MQTT broker.

Documentation/docs/reference/client_options.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
---
2-
sidebar_position: 45
3-
---
41
# HiveMQClientOptions
52

63
The `HiveMQClientOptions` class provides options for configuring the HiveMQ MQTT client.
@@ -121,6 +118,18 @@ The `HiveMQClientOptions` class provides options for configuring the HiveMQ MQTT
121118
* Type: `int`
122119
* Description: The time in milliseconds to wait for a connection to be established.
123120

121+
### `ResponseTimeoutInMs`
122+
-------------------------
123+
124+
* Type: `int`
125+
* Description: The time in milliseconds to wait for a response from transactional packets.
126+
127+
### `AutomaticReconnect`
128+
-------------------------
129+
130+
* Type: `bool`
131+
* Description: Indicates whether the client should automatically reconnect if the connection is lost or dropped.
132+
124133
## Constructors
125134
---------------
126135

Documentation/docs/reference/client_options_builder.md

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ The `HiveMQClientOptionsBuilder` class is a builder pattern implementation that
44

55
## Methods
66

7+
### `WithAutomaticReconnect(bool automaticReconnect)`
8+
9+
Sets whether the client should automatically reconnect when the connection is lost or dropped.
10+
11+
**Description:** This flag indicates whether the automatic reconnect system is enabled. Reconnection attempts are made periodically with a backing off strategy that maxes out at once per minute until reconnected.
12+
13+
**Example:** `WithAutomaticReconnect(true)`
14+
715
### `WithBroker(string broker)`
816

917
Sets the address of the broker to connect to.

0 commit comments

Comments
 (0)