MQTTClientOptions

public class MQTTClientOptions

MQTT client options for the CocoaMQTT client.

  • Broker host name or IP address (default “localhost”).

    Declaration

    Swift

    public var host: String
  • Broker port (default is 1883).

    Declaration

    Swift

    public var port: UInt16
  • Determines whether to try to discover a broker host/port by mDNS/Bonjour service (default is false).

    Declaration

    Swift

    public var shouldTryMDNSDiscovery: Bool
  • Username for secure connection (optional).

    Declaration

    Swift

    public var username: String?
  • Password for secure connection (optional).

    Declaration

    Swift

    public var password: String?
  • Whether to allow untrusted certificate roots or not.

    Declaration

    Swift

    public var allowUntrustCACertificate: Bool
  • Interval in which keep alive messages are sent (in seconds).

    Note

    Do not set keepAlive under 10 seconds. Otherwise it might happen that you will reconnect unnecessarily because of latency issues, especially if you are using a public broker.

    Declaration

    Swift

    public var keepAlive: UInt16
  • Whether to enable secure SSL connection.

    Declaration

    Swift

    public var enableSSL: Bool
  • Determines whether client should reconnect automatically if connection is closed abnormally.

    Declaration

    Swift

    public var autoReconnect: Bool
  • Auto reconnect time interval In seconds.

    Declaration

    Swift

    public var autoReconnectTimeInterval: Int
  • qos

    MQTT Quality of Service level (1, 2, 3) for publications, subscriptions, and last will messages (defaults to 0).

    Declaration

    Swift

    public var qos: Int
  • Determines whether to log MQTT protocol messages (defaults to false). Turn on for debugging only because output is rather abundant.

    Declaration

    Swift

    public var shouldLog: Bool
  • Create a new instance of MQTTClientOptions.

    Declaration

    Swift

    public init(host: String = "localhost",
    
         port: UInt16 = 1883,
    
         enableSSL: Bool = false,
    
         shouldTryMDNSDiscovery: Bool = false,
    
         username: String? = nil,
    
         password: String? = nil,
    
         keepAlive: UInt16 = 60,
    
         autoReconnect: Bool = true,
    
         allowUntrustCACertificate: Bool = false,
    
         autoReconnectTimeInterval: Int = 1,
    
         qos: Int = 0,
    
         shouldLog: Bool = false)