Show / Hide Table of Contents

    Class MqttClientConfiguration

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

    Inheritance
    object
    MqttClientConfiguration
    Implements
    IValidatableSettings
    IEquatable<MqttClientConfiguration>
    Inherited Members
    object.GetType()
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    Namespace: Silverback.Messaging.Configuration.Mqtt
    Assembly: Silverback.Integration.MQTT.dll
    Syntax
    public sealed record MqttClientConfiguration : IValidatableSettings, IEquatable<MqttClientConfiguration>

    Constructors

    MqttClientConfiguration()

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

    Declaration
    public MqttClientConfiguration()

    Properties

    AcknowledgmentTimeout

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

    Declaration
    public TimeSpan AcknowledgmentTimeout { get; init; }
    Property Value
    Type Description
    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.

    Declaration
    public bool AllowPacketFragmentation { get; init; }
    Property Value
    Type Description
    bool

    AuthenticationData

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

    Declaration
    public byte[]? AuthenticationData { get; init; }
    Property Value
    Type Description
    byte[]

    AuthenticationMethod

    Gets the custom authentication method.

    Declaration
    public string? AuthenticationMethod { get; init; }
    Property Value
    Type Description
    string

    BackpressureLimit

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

    Declaration
    public int BackpressureLimit { get; init; }
    Property Value
    Type Description
    int

    Channel

    Gets the channel configuration (either MqttClientTcpConfiguration or MqttClientWebSocketConfiguration).

    Declaration
    public MqttClientChannelConfiguration? Channel { get; init; }
    Property Value
    Type Description
    MqttClientChannelConfiguration

    CleanSession

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

    Declaration
    public bool CleanSession { get; init; }
    Property Value
    Type Description
    bool

    ClientId

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

    Declaration
    public string ClientId { get; init; }
    Property Value
    Type Description
    string

    ConsumerEndpoints

    Gets the configured consumer endpoints.

    Declaration
    public IValueReadOnlyCollection<MqttConsumerEndpointConfiguration> ConsumerEndpoints { get; init; }
    Property Value
    Type Description
    IValueReadOnlyCollection<MqttConsumerEndpointConfiguration>

    Credentials

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

    Declaration
    public IMqttClientCredentialsProvider? Credentials { get; init; }
    Property Value
    Type Description
    IMqttClientCredentialsProvider

    EnhancedAuthenticationHandler

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

    Declaration
    public IMqttEnhancedAuthenticationHandler? EnhancedAuthenticationHandler { get; init; }
    Property Value
    Type Description
    IMqttEnhancedAuthenticationHandler

    KeepAlivePeriod

    Gets the communication timeout. The default is 10 seconds.

    Declaration
    public TimeSpan KeepAlivePeriod { get; init; }
    Property Value
    Type Description
    TimeSpan

    MaxDegreeOfParallelism

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

    Declaration
    public int MaxDegreeOfParallelism { get; init; }
    Property Value
    Type Description
    int

    MaximumPacketSize

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

    Declaration
    public uint MaximumPacketSize { get; init; }
    Property Value
    Type Description
    uint

    ProducerEndpoints

    Gets the configured producer endpoints.

    Declaration
    public IValueReadOnlyCollection<MqttProducerEndpointConfiguration> ProducerEndpoints { get; init; }
    Property Value
    Type Description
    IValueReadOnlyCollection<MqttProducerEndpointConfiguration>

    ProtocolVersion

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

    Declaration
    public MqttProtocolVersion ProtocolVersion { get; init; }
    Property Value
    Type Description
    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.

    Declaration
    public ushort ReceiveMaximum { get; init; }
    Property Value
    Type Description
    ushort

    RequestProblemInformation

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

    Declaration
    public bool RequestProblemInformation { get; init; }
    Property Value
    Type Description
    bool

    RequestResponseInformation

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

    Declaration
    public bool RequestResponseInformation { get; init; }
    Property Value
    Type Description
    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.

    Declaration
    public uint SessionExpiryInterval { get; init; }
    Property Value
    Type Description
    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.

    Declaration
    public TimeSpan Timeout { get; init; }
    Property Value
    Type Description
    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.

    Declaration
    public ushort TopicAliasMaximum { get; init; }
    Property Value
    Type Description
    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.

    Declaration
    public bool TryPrivate { get; init; }
    Property Value
    Type Description
    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.

    Declaration
    public IValueReadOnlyCollection<MqttUserProperty> UserProperties { get; init; }
    Property Value
    Type Description
    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.

    Declaration
    public bool ValidateFeatures { get; init; }
    Property Value
    Type Description
    bool

    WillMessage

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

    Declaration
    public MqttLastWillMessageConfiguration? WillMessage { get; init; }
    Property Value
    Type Description
    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.

    Declaration
    public int WriterBufferSize { get; init; }
    Property Value
    Type Description
    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.

    Declaration
    public int WriterBufferSizeMax { get; init; }
    Property Value
    Type Description
    int

    Methods

    Equals(MqttClientConfiguration?)

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

    Declaration
    public bool Equals(MqttClientConfiguration? other)
    Parameters
    Type Name Description
    MqttClientConfiguration other
    Returns
    Type Description
    bool

    Equals(object?)

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

    Declaration
    public override bool Equals(object? obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    object.Equals(object)

    GetHashCode()

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

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    object.GetHashCode()

    ToString()

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

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()

    Validate()

    Throws a SilverbackConfigurationException if the configuration is not valid.

    Declaration
    public void Validate()

    Operators

    operator ==(MqttClientConfiguration?, MqttClientConfiguration?)

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

    Declaration
    public static bool operator ==(MqttClientConfiguration? left, MqttClientConfiguration? right)
    Parameters
    Type Name Description
    MqttClientConfiguration left
    MqttClientConfiguration right
    Returns
    Type Description
    bool

    operator !=(MqttClientConfiguration?, MqttClientConfiguration?)

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

    Declaration
    public static bool operator !=(MqttClientConfiguration? left, MqttClientConfiguration? right)
    Parameters
    Type Name Description
    MqttClientConfiguration left
    MqttClientConfiguration right
    Returns
    Type Description
    bool

    Implements

    IValidatableSettings
    IEquatable<T>
    GitHub E-Mail
    ↑ Back to top © 2026 Sergio Aquilini