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
boolisSettingFromConnStr
bool
MqttConnectionSettings(string, string)
public MqttConnectionSettings(string hostname, string clientId)
Parameters
Properties
CaFile
Path to a PEM file to validate server identity.
public string? CaFile { get; set; }
Property Value
CertFile
Path to a PEM file to establish X509 client authentication
public string? CertFile { get; set; }
Property Value
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
ClientCertificate
The client certificate for X509 authentication.
public X509Certificate2? ClientCertificate { get; set; }
Property Value
ClientId
The MQTT client Id that this client will use when connecting.
public string ClientId { get; set; }
Property Value
HostName
The fully qualified domain name of the MQTT broker.
public string HostName { get; set; }
Property Value
KeepAlive
The MQTT connection-level keep alive period.
public TimeSpan KeepAlive { get; set; }
Property Value
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
KeyPasswordFile
The file containing the password for accessing KeyFile.
public string? KeyPasswordFile { get; set; }
Property Value
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
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
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
SessionExpiry
The session expiry period that this client's connections will use.
public TimeSpan SessionExpiry { get; set; }
Property Value
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
TrustChain
The certificate authority to trust.
public X509Certificate2Collection? TrustChain { get; set; }
Property Value
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
Username
The MQTT connection username to include in the CONNECT packet.
public string? Username { get; set; }
Property Value
Methods
FromConnectionString(string)
public static MqttConnectionSettings FromConnectionString(string connectionString)
Parameters
connectionString
string
Returns
FromEnvVars()
public static MqttConnectionSettings FromEnvVars()
Returns
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
stringdefaultValue
bool
Returns
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
stringdefaultValue
int
Returns
GetStringValue(IDictionary<string, string>, string)
protected static string? GetStringValue(IDictionary<string, string> dict, string propertyName)
Parameters
dict
IDictionary<string, string>propertyName
string
Returns
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
stringdefaultValue
TimeSpan
Returns
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