Show / Hide Table of Contents

    Class MqttClientConfigBuilder

    Builds the MqttClientConfig.

    Inheritance
    object
    MqttClientConfigBuilder
    Implements
    IMqttClientConfigBuilder
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Silverback.Messaging.Configuration.Mqtt
    Assembly: Silverback.Integration.MQTT.dll
    Syntax
    public class MqttClientConfigBuilder : IMqttClientConfigBuilder

    Constructors

    | Improve this doc View source

    MqttClientConfigBuilder(MqttClientConfig, IServiceProvider?)

    Initializes a new instance of the MqttClientConfigBuilder class.

    Declaration
    public MqttClientConfigBuilder(MqttClientConfig baseConfig, IServiceProvider? serviceProvider = null)
    Parameters
    Type Name Description
    MqttClientConfig baseConfig

    The MqttClientConfig to be used to initialize the builder.

    IServiceProvider serviceProvider

    The IServiceProvider to be used to resolve the required types (e.g. the MQTTnet.Client.IMqttExtendedAuthenticationExchangeHandler).

    | Improve this doc View source

    MqttClientConfigBuilder(IServiceProvider?)

    Initializes a new instance of the MqttClientConfigBuilder class.

    Declaration
    public MqttClientConfigBuilder(IServiceProvider? serviceProvider = null)
    Parameters
    Type Name Description
    IServiceProvider serviceProvider

    The IServiceProvider to be used to resolve the required types (e.g. the MQTTnet.Client.IMqttExtendedAuthenticationExchangeHandler).

    Methods

    | Improve this doc View source

    AddUserProperty(string, string?)

    Adds a user property to be sent with the CONNECT packet. It can be used to send connection related properties from the client to the server.

    Declaration
    public IMqttClientConfigBuilder AddUserProperty(string name, string? value)
    Parameters
    Type Name Description
    string name

    The property name.

    string value

    The property value.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    Build()

    Builds the MqttClientConfig instance.

    Declaration
    public MqttClientConfig Build()
    Returns
    Type Description
    MqttClientConfig

    The MqttClientConfig.

    | Improve this doc View source

    ConnectTo(string)

    Specifies the URI of the server.

    Declaration
    [Obsolete("Use ConnectViaTcp or ConnectViaWebsocket.")]
    public IMqttClientConfigBuilder ConnectTo(string uri)
    Parameters
    Type Name Description
    string uri

    The server URI.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    ConnectTo(Uri)

    Specifies the URI of the server.

    Declaration
    [Obsolete("Use ConnectViaTcp or ConnectViaWebsocket.")]
    public IMqttClientConfigBuilder ConnectTo(Uri uri)
    Parameters
    Type Name Description
    Uri uri

    The server URI.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    ConnectViaTcp(Action<MqttClientTcpOptions>)

    Specifies the TCP connection settings.

    Declaration
    public IMqttClientConfigBuilder ConnectViaTcp(Action<MqttClientTcpOptions> optionsAction)
    Parameters
    Type Name Description
    Action<MqttClientTcpOptions> optionsAction

    An Action<T> that takes the MQTTnet.Client.MqttClientTcpOptions and configures it.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    ConnectViaTcp(string, int?, AddressFamily)

    Specifies the TCP connection settings.

    Declaration
    public IMqttClientConfigBuilder ConnectViaTcp(string server, int? port = null, AddressFamily addressFamily = AddressFamily.Unspecified)
    Parameters
    Type Name Description
    string server

    The server address.

    int? port

    The server port. If not specified the default port 1883 will be used.

    AddressFamily addressFamily

    The address family to use for the connection. The default is Unspecified.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    ConnectViaWebSocket(Action<MqttClientWebSocketOptionsBuilder>)

    Specifies the WebSocket connection settings.

    Declaration
    public IMqttClientConfigBuilder ConnectViaWebSocket(Action<MqttClientWebSocketOptionsBuilder> optionsAction)
    Parameters
    Type Name Description
    Action<MqttClientWebSocketOptionsBuilder> optionsAction

    An Action<T> that takes the MQTTnet.Client.MqttClientWebSocketOptionsBuilder and configures it.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    ConnectViaWebSocket(Action<MqttClientWebSocketOptions>)

    Specifies the WebSocket connection settings.

    Declaration
    [Obsolete("Use the overload with the builder as parameter.")]
    public IMqttClientConfigBuilder ConnectViaWebSocket(Action<MqttClientWebSocketOptions> optionsAction)
    Parameters
    Type Name Description
    Action<MqttClientWebSocketOptions> optionsAction

    An Action<T> that takes the MQTTnet.Client.MqttClientWebSocketOptions and configures it.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    ConnectViaWebSocket(string, MqttClientOptionsBuilderWebSocketParameters?)

    Specifies the WebSocket connection settings.

    Declaration
    [Obsolete("Use the overload with the builder as parameter.")]
    public IMqttClientConfigBuilder ConnectViaWebSocket(string uri, MqttClientOptionsBuilderWebSocketParameters? parameters = null)
    Parameters
    Type Name Description
    string uri

    The server URI.

    MqttClientOptionsBuilderWebSocketParameters parameters
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    ConnectViaWebSocket(string, Action<MqttClientOptionsBuilderWebSocketParameters>)

    Specifies the WebSocket connection settings.

    Declaration
    [Obsolete("Use the overload with the builder as parameter.")]
    public IMqttClientConfigBuilder ConnectViaWebSocket(string uri, Action<MqttClientOptionsBuilderWebSocketParameters> parametersAction)
    Parameters
    Type Name Description
    string uri

    The server URI.

    Action<MqttClientOptionsBuilderWebSocketParameters> parametersAction

    An Action<T> that takes the MQTTnet.Client.MqttClientOptionsBuilderWebSocketParameters and configures it.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    DisableKeepAlive()

    Disables the the keep alive mechanism. No ping packet will be sent.

    Declaration
    public IMqttClientConfigBuilder DisableKeepAlive()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    DisableProblemInformation()

    Specifies that the reason string or user properties can be sent with CONNACK or DISCONNECT packets only.

    Declaration
    public IMqttClientConfigBuilder DisableProblemInformation()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    DisableResponseInformation()

    Specifies that the server should not return the response information in the CONNACK packet. This is usually the default.

    Declaration
    public IMqttClientConfigBuilder DisableResponseInformation()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    DisableTls()

    Disables TLS. The network traffic will not be encrypted.

    Declaration
    public IMqttClientConfigBuilder DisableTls()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    EnableTls()

    Specifies that TLS has to be used to encrypt the network traffic.

    Declaration
    public IMqttClientConfigBuilder EnableTls()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    EnableTls(MqttClientOptionsBuilderTlsParameters)

    Specifies that TLS has to be used to encrypt the network traffic.

    Declaration
    [Obsolete("Use the overload with the new builder or model as parameter.")]
    public IMqttClientConfigBuilder EnableTls(MqttClientOptionsBuilderTlsParameters parameters)
    Parameters
    Type Name Description
    MqttClientOptionsBuilderTlsParameters parameters

    The MQTTnet.Client.MqttClientOptionsBuilderTlsParameters.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    EnableTls(MqttClientTlsOptions)

    Specifies that TLS has to be used to encrypt the network traffic.

    Declaration
    public IMqttClientConfigBuilder EnableTls(MqttClientTlsOptions options)
    Parameters
    Type Name Description
    MqttClientTlsOptions options

    The MQTTnet.Client.MqttClientTlsOptionsBuilder.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    EnableTls(Action<MqttClientOptionsBuilderTlsParameters>)

    Specifies that TLS has to be used to encrypt the network traffic.

    Declaration
    [Obsolete("Use the overload with the new builder or model as parameter.")]
    public IMqttClientConfigBuilder EnableTls(Action<MqttClientOptionsBuilderTlsParameters> parametersAction)
    Parameters
    Type Name Description
    Action<MqttClientOptionsBuilderTlsParameters> parametersAction

    An Action<T> that takes the MQTTnet.Client.MqttClientOptionsBuilderTlsParameters and configures it.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    EnableTls(Action<MqttClientTlsOptionsBuilder>)

    Specifies that TLS has to be used to encrypt the network traffic.

    Declaration
    public IMqttClientConfigBuilder EnableTls(Action<MqttClientTlsOptionsBuilder> optionsAction)
    Parameters
    Type Name Description
    Action<MqttClientTlsOptionsBuilder> optionsAction

    An Action<T> that takes the MQTTnet.Client.MqttClientTlsOptionsBuilder and configures it.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    LimitPacketSize(uint)

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

    Declaration
    public IMqttClientConfigBuilder LimitPacketSize(uint maximumPacketSize)
    Parameters
    Type Name Description
    uint maximumPacketSize

    The maximum packet size.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    LimitTopicAlias(int)

    Sets 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 IMqttClientConfigBuilder LimitTopicAlias(int topicAliasMaximum)
    Parameters
    Type Name Description
    int topicAliasMaximum

    The maximum number of topic aliases.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    LimitUnacknowledgedPublications(ushort)

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

    Declaration
    public IMqttClientConfigBuilder LimitUnacknowledgedPublications(ushort receiveMaximum)
    Parameters
    Type Name Description
    ushort receiveMaximum

    The maximum number of concurrent publications.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    Remarks

    There is no mechanism to limit the QoS 0 publications that the Server might try to send.

    | Improve this doc View source

    RequestCleanSession()

    Specifies that a clean non-persistent session has to be created for this client. This is the default, use RequestPersistentSession() to switch to a persistent session.

    Declaration
    public IMqttClientConfigBuilder RequestCleanSession()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    RequestPersistentSession()

    Specifies that a persistent session has to be created for this client.

    Declaration
    public IMqttClientConfigBuilder RequestPersistentSession()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    RequestProblemInformation()

    Specifies that the reason string or user properties can be sent with any packet. This is usually the default.

    Declaration
    public IMqttClientConfigBuilder RequestProblemInformation()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    RequestResponseInformation()

    Specifies that the server should return the response information in the CONNACK packet.

    Declaration
    public IMqttClientConfigBuilder RequestResponseInformation()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    SendKeepAlive(TimeSpan)

    Sets the maximum period that can elapse without a packet being sent to the message broker. When this period is elapsed a ping packet will be sent to keep the connection alive. The default is 15 seconds.

    Declaration
    public IMqttClientConfigBuilder SendKeepAlive(TimeSpan interval)
    Parameters
    Type Name Description
    TimeSpan interval

    The maximum period that can elapse without a packet being sent.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    SendLastWillMessage(Action<IMqttLastWillMessageBuilder>)

    Specifies the last will and testament (LWT) message to be sent when the client disconnects ungracefully.

    Declaration
    public IMqttClientConfigBuilder SendLastWillMessage(Action<IMqttLastWillMessageBuilder> lastWillBuilderAction)
    Parameters
    Type Name Description
    Action<IMqttLastWillMessageBuilder> lastWillBuilderAction

    An Action<T> that takes the IMqttLastWillMessageBuilder and configures it.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    UseExtendedAuthenticationExchangeHandler(IMqttExtendedAuthenticationExchangeHandler)

    Sets the handler to be used to handle the custom authentication data exchange.

    Declaration
    public IMqttClientConfigBuilder UseExtendedAuthenticationExchangeHandler(IMqttExtendedAuthenticationExchangeHandler handler)
    Parameters
    Type Name Description
    IMqttExtendedAuthenticationExchangeHandler handler

    The MQTTnet.Client.IMqttExtendedAuthenticationExchangeHandler instance to be used.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    UseExtendedAuthenticationExchangeHandler(Type)

    Sets the handler to be used to handle the custom authentication data exchange.

    Declaration
    public IMqttClientConfigBuilder UseExtendedAuthenticationExchangeHandler(Type handlerType)
    Parameters
    Type Name Description
    Type handlerType

    The type of the MQTTnet.Client.IMqttExtendedAuthenticationExchangeHandler to be used. The instance will be resolved via IServiceProvider.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    UseExtendedAuthenticationExchangeHandler<THandler>()

    Sets the handler to be used to handle the custom authentication data exchange.

    Declaration
    public IMqttClientConfigBuilder UseExtendedAuthenticationExchangeHandler<THandler>() where THandler : IMqttExtendedAuthenticationExchangeHandler
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    Type Parameters
    Name Description
    THandler

    The type of the MQTTnet.Client.IMqttExtendedAuthenticationExchangeHandler to be used. The instance will be resolved via IServiceProvider.

    | Improve this doc View source

    UseProtocolVersion(MqttProtocolVersion)

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

    Declaration
    public IMqttClientConfigBuilder UseProtocolVersion(MqttProtocolVersion value)
    Parameters
    Type Name Description
    MqttProtocolVersion value

    The MQTTnet.Formatter.MqttProtocolVersion.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    UseProxy(Action<MqttClientWebSocketProxyOptions>)

    Specifies the WebSocket connection settings.

    Declaration
    [Obsolete("Configure proxy in ConnectViaWebSocket(...).")]
    public IMqttClientConfigBuilder UseProxy(Action<MqttClientWebSocketProxyOptions> optionsAction)
    Parameters
    Type Name Description
    Action<MqttClientWebSocketProxyOptions> optionsAction

    An Action<T> that takes the MQTTnet.Client.MqttClientWebSocketProxyOptions and configures it.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    UseProxy(string, string?, string?, string?, bool, string[]?)

    Specifies the WebSocket proxy to be used.

    Declaration
    [Obsolete("Configure proxy in ConnectViaWebSocket(...).")]
    public IMqttClientConfigBuilder UseProxy(string address, string? username = null, string? password = null, string? domain = null, bool bypassOnLocal = false, string[]? bypassList = null)
    Parameters
    Type Name Description
    string address

    The proxy address.

    string username

    The user name to be used to authenticate against the proxy.

    string password

    The password to be used to authenticate against the proxy.

    string domain

    The user domain.

    bool bypassOnLocal

    A boolean value indicating whether the proxy must be bypassed for local addresses.

    string[] bypassList

    The bypass list.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    WithAuthentication(string?, byte[]?)

    Specifies the authentication method to be used and the associated data.

    Declaration
    public IMqttClientConfigBuilder WithAuthentication(string? method, byte[]? data)
    Parameters
    Type Name Description
    string method

    The authentication method.

    byte[] data

    The authentication data.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    WithClientId(string)

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

    Declaration
    public IMqttClientConfigBuilder WithClientId(string value)
    Parameters
    Type Name Description
    string value

    The client identifier.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    WithCredentials(IMqttClientCredentialsProvider)

    Sets the credential to be used to authenticate with the message broker.

    Declaration
    public IMqttClientConfigBuilder WithCredentials(IMqttClientCredentialsProvider credentialsProvider)
    Parameters
    Type Name Description
    IMqttClientCredentialsProvider credentialsProvider

    The MQTTnet.Client.IMqttClientCredentialsProvider.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    WithCredentials(string, byte[]?)

    Sets the credential to be used to authenticate with the message broker.

    Declaration
    public IMqttClientConfigBuilder WithCredentials(string username, byte[]? password = null)
    Parameters
    Type Name Description
    string username

    The user name.

    byte[] password

    The user password.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    WithCredentials(string, string?)

    Sets the credential to be used to authenticate with the message broker.

    Declaration
    public IMqttClientConfigBuilder WithCredentials(string username, string? password = null)
    Parameters
    Type Name Description
    string username

    The user name.

    string password

    The user password.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    WithSessionExpiration(TimeSpan)

    Sets the session expiry interval. 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 IMqttClientConfigBuilder WithSessionExpiration(TimeSpan sessionExpiryInterval)
    Parameters
    Type Name Description
    TimeSpan sessionExpiryInterval

    The TimeSpan representing the session expiry interval.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    WithTimeout(TimeSpan)

    Sets 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 IMqttClientConfigBuilder WithTimeout(TimeSpan timeout)
    Parameters
    Type Name Description
    TimeSpan timeout

    The TimeSpan representing the timeout.

    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    WithTryPrivate()

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

    Declaration
    public IMqttClientConfigBuilder WithTryPrivate()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    | Improve this doc View source

    WithoutTryPrivate()

    Set TryPrivate to false.

    Declaration
    public IMqttClientConfigBuilder WithoutTryPrivate()
    Returns
    Type Description
    IMqttClientConfigBuilder

    The IMqttClientConfigBuilder so that additional calls can be chained.

    Implements

    IMqttClientConfigBuilder
    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini