Interface IMqttClientConfigBuilder
Builds the MqttClientConfig.
Namespace: Silverback.Messaging.Configuration.Mqtt
Assembly: Silverback.Integration.MQTT.dll
Syntax
public interface IMqttClientConfigBuilder
Methods
| Improve this doc View sourceAddUserProperty(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
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. |
ConnectTo(string)
Specifies the URI of the server.
Declaration
[Obsolete("Use ConnectViaTcp or ConnectViaWebsocket.")]
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. |
ConnectTo(Uri)
Specifies the URI of the server.
Declaration
[Obsolete("Use ConnectViaTcp or ConnectViaWebsocket.")]
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. |
ConnectViaTcp(Action<MqttClientTcpOptions>)
Specifies the TCP connection settings.
Declaration
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. |
ConnectViaTcp(string, int?, AddressFamily)
Specifies the TCP connection settings.
Declaration
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. |
ConnectViaWebSocket(Action<MqttClientWebSocketOptionsBuilder>)
Specifies the WebSocket connection settings.
Declaration
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. |
ConnectViaWebSocket(Action<MqttClientWebSocketOptions>)
Specifies the WebSocket connection settings.
Declaration
[Obsolete("Use the overload with the builder as parameter.")]
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. |
ConnectViaWebSocket(string, MqttClientOptionsBuilderWebSocketParameters?)
Specifies the WebSocket connection settings.
Declaration
[Obsolete("Use the overload with the builder as parameter.")]
IMqttClientConfigBuilder ConnectViaWebSocket(string uri, MqttClientOptionsBuilderWebSocketParameters? parameters = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | uri | The server URI. |
| MqttClientOptionsBuilderWebSocketParameters | parameters | The optional MQTTnet.Client.MqttClientOptionsBuilderWebSocketParameters. |
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
ConnectViaWebSocket(string, Action<MqttClientOptionsBuilderWebSocketParameters>)
Specifies the WebSocket connection settings.
Declaration
[Obsolete("Use the overload with the builder as parameter.")]
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. |
DisableKeepAlive()
Disables the the keep alive mechanism. No ping packet will be sent.
Declaration
IMqttClientConfigBuilder DisableKeepAlive()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
DisableProblemInformation()
Specifies that the reason string or user properties can be sent with CONNACK or DISCONNECT packets only.
Declaration
IMqttClientConfigBuilder DisableProblemInformation()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
DisableResponseInformation()
Specifies that the server should not return the response information in the CONNACK packet. This is usually the default.
Declaration
IMqttClientConfigBuilder DisableResponseInformation()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
DisableTls()
Disables TLS. The network traffic will not be encrypted.
Declaration
IMqttClientConfigBuilder DisableTls()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
EnableTls()
Specifies that TLS has to be used to encrypt the network traffic.
Declaration
IMqttClientConfigBuilder EnableTls()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
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.")]
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. |
EnableTls(MqttClientTlsOptions)
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.")]
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. |
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.")]
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. |
EnableTls(Action<MqttClientTlsOptionsBuilder>)
Specifies that TLS has to be used to encrypt the network traffic.
Declaration
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. |
LimitPacketSize(uint)
Sets the maximum packet size in byte the client will process. The default is no limit.
Declaration
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. |
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
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. |
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
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.
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
IMqttClientConfigBuilder RequestCleanSession()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
RequestPersistentSession()
Specifies that a persistent session has to be created for this client.
Declaration
IMqttClientConfigBuilder RequestPersistentSession()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
RequestProblemInformation()
Specifies that the reason string or user properties can be sent with any packet. This is usually the default.
Declaration
IMqttClientConfigBuilder RequestProblemInformation()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
RequestResponseInformation()
Specifies that the server should return the response information in the CONNACK packet.
Declaration
IMqttClientConfigBuilder RequestResponseInformation()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
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
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. |
SendLastWillMessage(Action<IMqttLastWillMessageBuilder>)
Specifies the last will and testament (LWT) message to be sent when the client disconnects ungracefully.
Declaration
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. |
UseExtendedAuthenticationExchangeHandler(IMqttExtendedAuthenticationExchangeHandler)
Sets the handler to be used to handle the custom authentication data exchange.
Declaration
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. |
UseExtendedAuthenticationExchangeHandler(Type)
Sets the handler to be used to handle the custom authentication data exchange.
Declaration
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. |
UseExtendedAuthenticationExchangeHandler<THandler>()
Sets the handler to be used to handle the custom authentication data exchange.
Declaration
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. |
UseProtocolVersion(MqttProtocolVersion)
Specifies the MQTT protocol version. The default is MQTTnet.Formatter.MqttProtocolVersion.V500.
Declaration
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. |
UseProxy(Action<MqttClientWebSocketProxyOptions>)
Specifies the WebSocket connection settings.
Declaration
[Obsolete("Configure proxy in ConnectViaWebSocket(...).")]
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. |
UseProxy(string, string?, string?, string?, bool, string[]?)
Specifies the WebSocket proxy to be used.
Declaration
[Obsolete("Configure proxy in ConnectViaWebSocket(...).")]
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. |
WithAuthentication(string?, byte[]?)
Specifies the authentication method to be used and the associated data.
Declaration
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. |
WithClientId(string)
Sets the client identifier. The default is Guid.NewGuid().ToString().
Declaration
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. |
WithCredentials(IMqttClientCredentialsProvider)
Sets the credential to be used to authenticate with the message broker.
Declaration
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. |
WithCredentials(string, byte[]?)
Sets the credential to be used to authenticate with the message broker.
Declaration
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. |
WithCredentials(string, string?)
Sets the credential to be used to authenticate with the message broker.
Declaration
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. |
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
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. |
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
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. |
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
IMqttClientConfigBuilder WithTryPrivate()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |
WithoutTryPrivate()
Set TryPrivate to false.
Declaration
IMqttClientConfigBuilder WithoutTryPrivate()
Returns
| Type | Description |
|---|---|
| IMqttClientConfigBuilder | The IMqttClientConfigBuilder so that additional calls can be chained. |