Table of Contents

Class MqttConnectionSettings

Namespace
Azure.Iot.Operations.Protocol.Connection
Assembly
Azure.Iot.Operations.Protocol.dll
public class MqttConnectionSettings
Inheritance
MqttConnectionSettings
Inherited Members

Constructors

MqttConnectionSettings(IDictionary<string, string>, bool, bool)

protected MqttConnectionSettings(IDictionary<string, string> connectionSettings, bool validateOptionalSettings, bool isSettingFromConnStr = false)

Parameters

connectionSettings IDictionary<string, string>
validateOptionalSettings bool
isSettingFromConnStr bool

MqttConnectionSettings(string, string)

public MqttConnectionSettings(string hostname, string clientId)

Parameters

hostname string
clientId string

Properties

CaFile

Path to a PEM file to validate server identity.

public string? CaFile { get; set; }

Property Value

string

CertFile

Path to a PEM file to establish X509 client authentication

public string? CertFile { get; set; }

Property Value

string

CleanStart

If true, the client will connect to the MQTT broker without attempting to resume an MQTT session. If false, the client will try to resume an MQTT session if one is present.

public bool CleanStart { get; set; }

Property Value

bool

ClientCertificate

The client certificate for X509 authentication.

public X509Certificate2? ClientCertificate { get; set; }

Property Value

X509Certificate2

ClientId

The MQTT client Id that this client will use when connecting.

public string ClientId { get; set; }

Property Value

string

HostName

The fully qualified domain name of the MQTT broker.

public string HostName { get; set; }

Property Value

string

KeepAlive

The MQTT connection-level keep alive period.

public TimeSpan KeepAlive { get; set; }

Property Value

TimeSpan

Remarks

Higher values cause less network traffic, but lower values lead to faster responses to connection loss.

KeyFile

Path to a KEY file to establish X509 client authentication

public string? KeyFile { get; set; }

Property Value

string

KeyPasswordFile

The file containing the password for accessing KeyFile.

public string? KeyPasswordFile { get; set; }

Property Value

string

PasswordFile

The path to the file that contains the MQTT connection password to include in the CONNECT packet.

public string? PasswordFile { get; set; }

Property Value

string

ReceiveMaximum

The upper bound of concurrent in-flight QoS 1 or QoS 2 messages that the broker will be allowed to send to this client.

public ushort? ReceiveMaximum { get; set; }

Property Value

ushort?

SatAuthFile

The file that contains the shared access token used for authentication. Only applicable for applications deployed in kubernetes pods.

public string? SatAuthFile { get; set; }

Property Value

string

SessionExpiry

The session expiry period that this client's connections will use.

public TimeSpan SessionExpiry { get; set; }

Property Value

TimeSpan

Remarks

Longer periods allow for the client to reconnect and re-establish the MQTT session after longer delays.

TcpPort

The TCP port to use when connecting to the MQTT broker.

public int TcpPort { get; set; }

Property Value

int

TrustChain

The certificate authority to trust.

public X509Certificate2Collection? TrustChain { get; set; }

Property Value

X509Certificate2Collection

Remarks

If provided, this field supercedes any value provided in CaFile.

UseTls

Enable TLS negotiation (disabling not recommended for production).

public bool UseTls { get; set; }

Property Value

bool

Username

The MQTT connection username to include in the CONNECT packet.

public string? Username { get; set; }

Property Value

string

Methods

FromConnectionString(string)

public static MqttConnectionSettings FromConnectionString(string connectionString)

Parameters

connectionString string

Returns

MqttConnectionSettings

FromEnvVars()

public static MqttConnectionSettings FromEnvVars()

Returns

MqttConnectionSettings

GetBooleanValue(IDictionary<string, string>, string, bool)

protected static bool GetBooleanValue(IDictionary<string, string> dict, string propertyName, bool defaultValue = false)

Parameters

dict IDictionary<string, string>
propertyName string
defaultValue bool

Returns

bool

GetPositiveIntValueOrDefault(IDictionary<string, string>, string, int)

protected static int GetPositiveIntValueOrDefault(IDictionary<string, string> dict, string propertyName, int defaultValue = 0)

Parameters

dict IDictionary<string, string>
propertyName string
defaultValue int

Returns

int

GetStringValue(IDictionary<string, string>, string)

protected static string? GetStringValue(IDictionary<string, string> dict, string propertyName)

Parameters

dict IDictionary<string, string>
propertyName string

Returns

string

GetTimeSpanValue(IDictionary<string, string>, string, TimeSpan)

protected static TimeSpan GetTimeSpanValue(IDictionary<string, string> dict, string propertyName, TimeSpan defaultValue = default)

Parameters

dict IDictionary<string, string>
propertyName string
defaultValue TimeSpan

Returns

TimeSpan

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

ValidateMqttSettings(bool)

protected void ValidateMqttSettings(bool validateOptionalSettings)

Parameters

validateOptionalSettings bool