Skip to content

Commit

Permalink
New Automatic Reconnect Ability (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
pglombardo authored Jul 5, 2024
1 parent f51e332 commit 332109b
Show file tree
Hide file tree
Showing 17 changed files with 2,252 additions and 2,338 deletions.
30 changes: 24 additions & 6 deletions Documentation/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,33 @@ sidebar_position: 10

# The MQTT Client

* **Easy-to-Install**: Available as a Nuget package.
* **Opensource**: No blackbox code. Only trusted, tested and reviewed opensource code.
### 💽 Installation & Compatibility
* **Easy-to-Install**: Available as a [Nuget package](https://www.nuget.org/packages/HiveMQtt).
* **Globally Compatible**: Built to be a fully compliant MQTT 5.0 client compatible with all modern MQTT brokers.
* **Multi-Targeted**: Supports .NET 6.0, 7.0 & 8.0

### 🚀 Features
* **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.
* **Back Pressure Management**: Automatically manages back pressure to prevent overwhelming the broker (or client), ensuring reliable and efficient communication.
* **Asynchronous Design**: Designed for high-performance and low-latency communication, allowing your application to process multiple messages concurrently.
* **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).
* **Global and Per-Subscription Message Handling**: Use multiple targeted handlers for more targeted and specialized message processing.
* **Full Last Will & Testament Support**: Reliable message delivery and notification of client disconnections.
* **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.
* **Observable**: Configure up to [TRACE level logging](https://hivemq.github.io/hivemq-mqtt-client-dotnet/docs/how-to/debug) for package internals.
* **Fast**: Optimized & benchmarked. See the benchmark results [here](https://github.com/hivemq/hivemq-mqtt-client-dotnet/blob/main/Benchmarks/ClientBenchmarkApp/README.md).

### 🏝️ Ease of Use
* **Easy to Use**: Smart defaults, excellent interfaces and intelligent automation makes implementing a breeze.
* **MQTT v5.0 compatible**: Backported versions 3.1.1 & 3.0 coming soon!
* **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).
* **Globally Compatible**: Built to be a fully compliant client compatible with all reputable MQTT brokers.
* **Easy Integration**: Simple and intuitive API makes it easy to integrate with your .NET applications.

### 🛟 Maintenance and Support
* **Actively Maintained**: Built by the MQTT professionals that built HiveMQ (and do this for a living).
* **Extensively Documented**: What good is it without excellent documentation?
* **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/).
* **Extensively Documented**: What good is it without [excellent documentation](https://hivemq.github.io/hivemq-mqtt-client-dotnet/)?

### 🐧 Opensource
* **Opensource**: No blackbox code. Only trusted, tested and reviewed opensource code.

## What is this?

Expand Down
26 changes: 26 additions & 0 deletions Documentation/docs/reference/automatic_reconnect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Automatic Reconnect

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.

# Example

```csharp
var options = new HiveMQClientOptionsBuilder()
.WithAutomaticReconnect(true)
.Build();

// Create a new client with the configured options
var client = new HiveMQttClient(options);
```

# Backoff Strategy

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.

# Maximum Attempts

The backoff strategy will attempt to reconnect a maximum of once per minute. The client will attempt to reconnect indefinitely until successful.

# Summary

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.
15 changes: 12 additions & 3 deletions Documentation/docs/reference/client_options.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
---
sidebar_position: 45
---
# HiveMQClientOptions

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

### `ResponseTimeoutInMs`
-------------------------

* Type: `int`
* Description: The time in milliseconds to wait for a response from transactional packets.

### `AutomaticReconnect`
-------------------------

* Type: `bool`
* Description: Indicates whether the client should automatically reconnect if the connection is lost or dropped.

## Constructors
---------------

Expand Down
8 changes: 8 additions & 0 deletions Documentation/docs/reference/client_options_builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ The `HiveMQClientOptionsBuilder` class is a builder pattern implementation that

## Methods

### `WithAutomaticReconnect(bool automaticReconnect)`

Sets whether the client should automatically reconnect when the connection is lost or dropped.

**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.

**Example:** `WithAutomaticReconnect(true)`

### `WithBroker(string broker)`

Sets the address of the broker to connect to.
Expand Down
Loading

0 comments on commit 332109b

Please sign in to comment.