Table of Contents

Class MqttClientOptions

Namespace
MQTTnet.Client
Assembly
MQTTnet.dll
public sealed class MqttClientOptions
Inheritance
MqttClientOptions
Inherited Members

Constructors

MqttClientOptions()

public MqttClientOptions()

Properties

AllowPacketFragmentation

Usually the MQTT packets can be send partially. This is done by using multiple TCP packets or WebSocket frames etc. Unfortunately not all brokers (like Amazon Web Services (AWS)) do support this feature and will close the connection when receiving such packets. If such a service is used this flag must be set to false.

public bool AllowPacketFragmentation { get; set; }

Property Value

bool

AuthenticationData

Gets or sets the authentication data. MQTT 5.0.0+ feature.

public byte[] AuthenticationData { get; set; }

Property Value

byte[]

AuthenticationMethod

Gets or sets the authentication method. MQTT 5.0.0+ feature.

public string AuthenticationMethod { get; set; }

Property Value

string

ChannelOptions

public IMqttClientChannelOptions ChannelOptions { get; set; }

Property Value

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.

public bool CleanSession { get; set; }

Property Value

bool

ClientId

Gets the client identifier. Hint: This identifier needs to be unique over all used clients / devices on the broker to avoid connection issues.

public string ClientId { get; set; }

Property Value

string

Credentials

public IMqttClientCredentialsProvider Credentials { get; set; }

Property Value

IMqttClientCredentialsProvider

ExtendedAuthenticationExchangeHandler

public IMqttExtendedAuthenticationExchangeHandler ExtendedAuthenticationExchangeHandler { get; set; }

Property Value

IMqttExtendedAuthenticationExchangeHandler

KeepAlivePeriod

Gets or sets the keep alive period. The connection is normally left open by the client so that is can send and receive data at any time. If no data flows over an open connection for a certain time period then the client will generate a PINGREQ and expect to receive a PINGRESP from the broker. This message exchange confirms that the connection is open and working. This period is known as the keep alive period.

public TimeSpan KeepAlivePeriod { get; set; }

Property Value

TimeSpan

MaximumPacketSize

Gets or sets the maximum packet size. MQTT 5.0.0+ feature.

public uint MaximumPacketSize { get; set; }

Property Value

uint

ProtocolVersion

public MqttProtocolVersion ProtocolVersion { get; set; }

Property Value

MqttProtocolVersion

ReceiveMaximum

Gets or sets the receive maximum. This gives the maximum length of the receive messages. MQTT 5.0.0+ feature.

public ushort ReceiveMaximum { get; set; }

Property Value

ushort

RequestProblemInformation

Gets or sets the request problem information. MQTT 5.0.0+ feature.

public bool RequestProblemInformation { get; set; }

Property Value

bool

RequestResponseInformation

Gets or sets the request response information. MQTT 5.0.0+ feature.

public bool RequestResponseInformation { get; set; }

Property Value

bool

SessionExpiryInterval

Gets or sets the session expiry interval. The time after a session expires when it's not actively used. MQTT 5.0.0+ feature.

public uint SessionExpiryInterval { get; set; }

Property Value

uint

ThrowOnNonSuccessfulConnectResponse

Gets or sets whether an exception should be thrown when the server has sent a non success ACK packet.

public bool ThrowOnNonSuccessfulConnectResponse { get; set; }

Property Value

bool

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.

public TimeSpan Timeout { get; set; }

Property Value

TimeSpan

TopicAliasMaximum

Gets or sets the topic alias maximum. This gives the maximum length of the topic alias. MQTT 5.0.0+ feature.

public ushort TopicAliasMaximum { get; set; }

Property Value

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.

public bool TryPrivate { get; set; }

Property Value

bool

UserProperties

Gets or sets 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. MQTT 5.0.0+ feature.

public List<MqttUserProperty> UserProperties { get; set; }

Property Value

List<MqttUserProperty>

ValidateFeatures

When this feature is enabled the client will check if used properties are supported in the selected protocol version. This feature can be validated if an application message is generated one time but sent via different protocol versions. Default values are applied if the validation is off and features are not supported.

public bool ValidateFeatures { get; set; }

Property Value

bool

WillContentType

Gets or sets the content type of the will message. MQTT 5.0.0+ feature.

public string WillContentType { get; set; }

Property Value

string

WillCorrelationData

Gets or sets the correlation data of the will message. MQTT 5.0.0+ feature.

public byte[] WillCorrelationData { get; set; }

Property Value

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. MQTT 5.0.0+ feature.

public uint WillDelayInterval { get; set; }

Property Value

uint

WillMessageExpiryInterval

Gets or sets the message expiry interval of the will message. MQTT 5.0.0+ feature.

public uint WillMessageExpiryInterval { get; set; }

Property Value

uint

WillPayload

Gets or sets the payload of the will message.

public byte[] WillPayload { get; set; }

Property Value

byte[]

WillPayloadFormatIndicator

Gets or sets the payload format indicator of the will message. MQTT 5.0.0+ feature.

public MqttPayloadFormatIndicator WillPayloadFormatIndicator { get; set; }

Property Value

MqttPayloadFormatIndicator

WillQualityOfServiceLevel

Gets or sets the QoS level of the will message.

public MqttQualityOfServiceLevel WillQualityOfServiceLevel { get; set; }

Property Value

MqttQualityOfServiceLevel

WillResponseTopic

Gets or sets the response topic of the will message. MQTT 5.0.0+ feature.

public string WillResponseTopic { get; set; }

Property Value

string

WillRetain

Gets or sets the retain flag of the will message.

public bool WillRetain { get; set; }

Property Value

bool

WillTopic

Gets or sets the topic of the will message.

public string WillTopic { get; set; }

Property Value

string

WillUserProperties

Gets or sets the user properties of the will message. MQTT 5.0.0+ feature.

public List<MqttUserProperty> WillUserProperties { get; set; }

Property Value

List<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.

public int WriterBufferSize { get; set; }

Property Value

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.

public int WriterBufferSizeMax { get; set; }

Property Value

int