Class MqttClientConfig
The configuration used to connect with the MQTT broker. This is actually a wrapper around the MQTTnet.Client.MqttClientOptions from the MQTTnet library.
Inherited Members
Namespace: Silverback.Messaging.Configuration.Mqtt
Assembly: Silverback.Integration.MQTT.dll
Syntax
public sealed class MqttClientConfig : IEquatable<MqttClientConfig>, IValidatableEndpointSettings
Constructors
| Improve this doc View sourceMqttClientConfig(MqttClientOptions?)
Initializes a new instance of the MqttClientConfig class.
Declaration
public MqttClientConfig(MqttClientOptions? clientOptions = null)
Parameters
Type | Name | Description |
---|---|---|
MqttClientOptions | clientOptions | The MQTTnet.Client.MqttClientOptions to be wrapped. |
Properties
| Improve this doc View sourceAuthenticationData
Gets or sets the authentication data. Hint: MQTT 5 feature only.
Declaration
public byte[]? AuthenticationData { get; set; }
Property Value
Type | Description |
---|---|
byte[] |
AuthenticationMethod
Gets or sets the authentication method. Hint: MQTT 5 feature only.
Declaration
public string? AuthenticationMethod { get; set; }
Property Value
Type | Description |
---|---|
string |
ChannelOptions
Gets or sets the channel options (either MQTTnet.Client.MqttClientTcpOptions or MQTTnet.Client.MqttClientWebSocketOptions).
Declaration
public IMqttClientChannelOptions? ChannelOptions { get; set; }
Property Value
Type | Description |
---|---|
IMqttClientChannelOptions |
CleanSession
Gets or sets a value indicating whether clean sessions are used or not. When a client connects to a broker it can connect using either a non persistent connection (clean session) or a persistent connection. With a non persistent connection the broker doesn't store any subscription information or undelivered messages for the client. This mode is ideal when the client only publishes messages. It can also connect as a durable client using a persistent connection. In this mode, the broker will store subscription information, and undelivered messages for the client.
Declaration
public bool CleanSession { get; set; }
Property Value
Type | Description |
---|---|
bool |
ClientId
Gets or sets the client identifier. Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.
Declaration
public string ClientId { get; set; }
Property Value
Type | Description |
---|---|
string |
Credentials
Gets or sets the credential to be used to authenticate with the message broker.
Declaration
public IMqttClientCredentialsProvider? Credentials { get; set; }
Property Value
Type | Description |
---|---|
IMqttClientCredentialsProvider |
ExtendedAuthenticationExchangeHandler
Gets or sets the handler to be used to handle the custom authentication data exchange.
Declaration
public IMqttExtendedAuthenticationExchangeHandler? ExtendedAuthenticationExchangeHandler { get; set; }
Property Value
Type | Description |
---|---|
IMqttExtendedAuthenticationExchangeHandler |
KeepAlivePeriod
Gets or 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 TimeSpan KeepAlivePeriod { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
MaximumPacketSize
Gets or sets the maximum packet size in byte the client will process. The default is no limit.
Declaration
public uint MaximumPacketSize { get; set; }
Property Value
Type | Description |
---|---|
uint |
ProtocolVersion
Gets or sets the MQTT protocol version. The default is MQTTnet.Formatter.MqttProtocolVersion.V500.
Declaration
public MqttProtocolVersion ProtocolVersion { get; set; }
Property Value
Type | Description |
---|---|
MqttProtocolVersion |
ReceiveMaximum
Gets or sets the receive maximum. This gives the maximum length of the receive messages.
Declaration
public ushort ReceiveMaximum { get; set; }
Property Value
Type | Description |
---|---|
ushort |
RequestProblemInformation
Gets or sets a value indicating whether the problem information must be requested. Hint: MQTT 5 feature only.
Declaration
public bool RequestProblemInformation { get; set; }
Property Value
Type | Description |
---|---|
bool |
RequestResponseInformation
Gets or sets a value indicating whether the response information must be requested. Hint: MQTT 5 feature only.
Declaration
public bool RequestResponseInformation { get; set; }
Property Value
Type | Description |
---|---|
bool |
SessionExpiryInterval
Gets or sets the session expiry interval. The time after a session expires when it's not actively used.
Declaration
public uint SessionExpiryInterval { get; set; }
Property Value
Type | Description |
---|---|
uint |
Timeout
Gets or 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 TimeSpan Timeout { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
TopicAliasMaximum
Gets or sets the topic alias maximum. This gives the maximum length of the topic alias.
Declaration
public ushort TopicAliasMaximum { get; set; }
Property Value
Type | Description |
---|---|
ushort |
TryPrivate
If set to true, 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 set it to false if your bridge does not connect properly.
Declaration
public bool TryPrivate { get; set; }
Property Value
Type | Description |
---|---|
bool |
UserProperties
Gets the user properties. In MQTT 5, user properties are basic UTF-8 string key-value pairs that you can append to almost every type of MQTT packet. As long as you don’t exceed the maximum message size, you can use an unlimited number of user properties to add metadata to MQTT messages and pass information between publisher, broker, and subscriber. The feature is very similar to the HTTP header concept. Hint: MQTT 5 feature only.
Declaration
public IList<MqttUserProperty> UserProperties { get; }
Property Value
Type | Description |
---|---|
IList<MqttUserProperty> |
WillContentType
Gets or sets the content type of the will message.
Declaration
public string WillContentType { get; set; }
Property Value
Type | Description |
---|---|
string |
WillCorrelationData
Gets or sets the correlation data of the will message.
Declaration
public byte[] WillCorrelationData { get; set; }
Property Value
Type | Description |
---|---|
byte[] |
WillDelayInterval
Gets or sets the will delay interval. This is the time between the client disconnect and the time the will message will be sent.
Declaration
public uint WillDelayInterval { get; set; }
Property Value
Type | Description |
---|---|
uint |
WillMessageExpiryInterval
Gets or sets the message expiry interval of the will message.
Declaration
public uint WillMessageExpiryInterval { get; set; }
Property Value
Type | Description |
---|---|
uint |
WillPayload
Gets or sets the payload of the will message.
Declaration
public byte[] WillPayload { get; set; }
Property Value
Type | Description |
---|---|
byte[] |
WillPayloadFormatIndicator
Gets or sets the payload format indicator of the will message.
Declaration
public MqttPayloadFormatIndicator WillPayloadFormatIndicator { get; set; }
Property Value
Type | Description |
---|---|
MqttPayloadFormatIndicator |
WillQualityOfServiceLevel
Gets or sets the QoS level of the will message.
Declaration
public MqttQualityOfServiceLevel WillQualityOfServiceLevel { get; set; }
Property Value
Type | Description |
---|---|
MqttQualityOfServiceLevel |
WillResponseTopic
Gets or sets the response topic of the will message.
Declaration
public string WillResponseTopic { get; set; }
Property Value
Type | Description |
---|---|
string |
WillRetain
Gets or sets the retain flag of the will message.
Declaration
public bool WillRetain { get; set; }
Property Value
Type | Description |
---|---|
bool |
WillTopic
Gets or sets the topic of the will message.
Declaration
public string WillTopic { get; set; }
Property Value
Type | Description |
---|---|
string |
WillUserProperties
Gets the user properties of the will message.
Declaration
public IList<MqttUserProperty> WillUserProperties { get; }
Property Value
Type | Description |
---|---|
IList<MqttUserProperty> |
WriterBufferSize
Gets or sets 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; set; }
Property Value
Type | Description |
---|---|
int |
WriterBufferSizeMax
Gets or sets 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; set; }
Property Value
Type | Description |
---|---|
int |
Methods
| Improve this doc View sourceEquals(MqttClientConfig?)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(MqttClientConfig? other)
Parameters
Type | Name | Description |
---|---|---|
MqttClientConfig | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Equals(object?)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
| Improve this doc View sourceGetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
| Improve this doc View sourceValidate()
Throws an EndpointConfigurationException if the current configuration is not valid.
Declaration
public void Validate()