Table of Contents

Class MqttClientConfiguration

Namespace
Silverback.Messaging.Configuration.Mqtt
Assembly
Silverback.Integration.MQTT.dll

The configuration used to connect with the MQTT broker. This is actually a wrapper around the MQTTnet.MqttClientOptions from the MQTTnet library.

public sealed record MqttClientConfiguration : IValidatableSettings, IEquatable<MqttClientConfiguration>
Inheritance
MqttClientConfiguration
Implements
Inherited Members

Constructors

MqttClientConfiguration()

public MqttClientConfiguration()

Properties

AcknowledgmentTimeout

Gets the maximum time to wait for the acknowledgment operation to complete. The default is 30 seconds.

public TimeSpan AcknowledgmentTimeout { get; init; }

Property Value

TimeSpan

AllowPacketFragmentation

Gets a value indicating whether the broker allows packet fragmentation. Unfortunately not all brokers (like AWS) do support fragmentation and will close the connection when receiving such packets. If such a service is used this flag must be set to false. The default is true.

public bool AllowPacketFragmentation { get; init; }

Property Value

bool

AuthenticationData

Gets the authentication data to be used for the custom authentication.

public byte[]? AuthenticationData { get; init; }

Property Value

byte[]

AuthenticationMethod

Gets the custom authentication method.

public string? AuthenticationMethod { get; init; }

Property Value

string

BackpressureLimit

Gets the maximum number of messages to be consumed and enqueued waiting to be processed. The default is 2.

public int BackpressureLimit { get; init; }

Property Value

int

Channel

Gets the channel configuration (either MqttClientTcpConfiguration or MqttClientWebSocketConfiguration).

public MqttClientChannelConfiguration? Channel { get; init; }

Property Value

MqttClientChannelConfiguration

CleanSession

Gets a value indicating whether a clean non-persistent session has to be created for this client. The default is true.

public bool CleanSession { get; init; }

Property Value

bool

ClientId

Gets the client identifier. The default is Guid.NewGuid().ToString().

public string ClientId { get; init; }

Property Value

string

ConsumerEndpoints

Gets the configured consumer endpoints.

public IValueReadOnlyCollection<MqttConsumerEndpointConfiguration> ConsumerEndpoints { get; init; }

Property Value

IValueReadOnlyCollection<MqttConsumerEndpointConfiguration>

Credentials

Gets the credentials to be used to authenticate with the message broker.

public IMqttClientCredentialsProvider? Credentials { get; init; }

Property Value

IMqttClientCredentialsProvider

EnhancedAuthenticationHandler

Gets the handler for AUTH packets. This can happen when connecting or at any time while being already connected.

public IMqttEnhancedAuthenticationHandler? EnhancedAuthenticationHandler { get; init; }

Property Value

IMqttEnhancedAuthenticationHandler

KeepAlivePeriod

Gets the communication timeout. The default is 10 seconds.

public TimeSpan KeepAlivePeriod { get; init; }

Property Value

TimeSpan

MaxDegreeOfParallelism

Gets the maximum number of incoming messages that can be processed concurrently. The default is 1.

public int MaxDegreeOfParallelism { get; init; }

Property Value

int

MaximumPacketSize

Gets the maximum packet size in byte the client will process. The default is no limit.

public uint MaximumPacketSize { get; init; }

Property Value

uint

ProducerEndpoints

Gets the configured producer endpoints.

public IValueReadOnlyCollection<MqttProducerEndpointConfiguration> ProducerEndpoints { get; init; }

Property Value

IValueReadOnlyCollection<MqttProducerEndpointConfiguration>

ProtocolVersion

Gets the MQTT protocol version. The default is MQTTnet.Formatter.MqttProtocolVersion.V500.

public MqttProtocolVersion ProtocolVersion { get; init; }

Property Value

MqttProtocolVersion

ReceiveMaximum

Gets the maximum number of QoS 1 and QoS 2 publications that can be received and processed concurrently. The default value is null, which means 65'535.

public ushort ReceiveMaximum { get; init; }

Property Value

ushort

RequestProblemInformation

Gets a value indicating whether the reason string or user properties can be sent with any packet. The default is usually true.

public bool RequestProblemInformation { get; init; }

Property Value

bool

RequestResponseInformation

Gets a value indicating whether the server should return the response information in the CONNACK packet. The default is usually false.

public bool RequestResponseInformation { get; init; }

Property Value

bool

SessionExpiryInterval

Gets the session expiry interval in seconds. When set to 0 the session will expire when the connection is closed, while MaxValue indicates that the session will never expire. The default is 0.

public uint SessionExpiryInterval { get; init; }

Property Value

uint

Timeout

Gets the timeout which will be applied at socket level and internal operations. The default value is the same as for sockets in .NET in general.

public TimeSpan Timeout { get; init; }

Property Value

TimeSpan

TopicAliasMaximum

Gets the maximum number of topic aliases the server can send in the PUBLISH packet. The default is 0, meaning that no alias can be sent.

public ushort TopicAliasMaximum { get; init; }

Property Value

ushort

TryPrivate

Gets a value indicating whether the bridge must attempt to indicate to the remote broker that it is a bridge and not an ordinary client. If successful, this means that the loop detection will be more effective and that the retained messages will be propagated correctly. Not all brokers support this feature, so it may be necessary to set it to false if your bridge does not connect properly.

public bool TryPrivate { get; init; }

Property Value

bool

UserProperties

Gets the list of user properties to be sent with the CONNECT packet. They can be used to send connection related properties from the client to the server.

public IValueReadOnlyCollection<MqttUserProperty> UserProperties { get; init; }

Property Value

IValueReadOnlyCollection<MqttUserProperty>

ValidateFeatures

Gets a value indicating whether the client should check if the configuration is valid for the selected protocol version. The default is true.

public bool ValidateFeatures { get; init; }

Property Value

bool

WillMessage

Gets the optional last will message to be sent when the client ungracefully disconnects.

public MqttLastWillMessageConfiguration? WillMessage { get; init; }

Property Value

MqttLastWillMessageConfiguration

WriterBufferSize

Gets the default and initial size of the packet write buffer. It is recommended to set this to a value close to the usual expected packet size * 1.5. Do not change this value when no memory issues are experienced.

public int WriterBufferSize { get; init; }

Property Value

int

WriterBufferSizeMax

Gets the maximum size of the buffer writer. The writer will reduce its internal buffer to this value after serializing a packet. Do not change this value when no memory issues are experienced.

public int WriterBufferSizeMax { get; init; }

Property Value

int

Methods

Equals(MqttClientConfiguration?)

public bool Equals(MqttClientConfiguration? other)

Parameters

other MqttClientConfiguration

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Validate()

Throws a SilverbackConfigurationException if the configuration is not valid.

public void Validate()

Operators

operator ==(MqttClientConfiguration?, MqttClientConfiguration?)

public static bool operator ==(MqttClientConfiguration? left, MqttClientConfiguration? right)

Parameters

left MqttClientConfiguration
right MqttClientConfiguration

Returns

bool

operator !=(MqttClientConfiguration?, MqttClientConfiguration?)

public static bool operator !=(MqttClientConfiguration? left, MqttClientConfiguration? right)

Parameters

left MqttClientConfiguration
right MqttClientConfiguration

Returns

bool