Documentation

ConnectionSettings
in package

The settings used during connection to a broker.

This class is immutable and all setters return a clone of the original class because connection settings must not change once passed to MqttClient.

Table of Contents

$connectTimeout  : int
$delayBetweenReconnectAttempts  : int
$keepAliveInterval  : int
$lastWillMessage  : string|null
$lastWillQualityOfService  : int
$lastWillRetain  : bool
$lastWillTopic  : string|null
$maxReconnectAttempts  : int
$password  : string|null
$reconnectAutomatically  : bool
$resendTimeout  : int
$socketTimeout  : int
$tlsCertificateAuthorityFile  : string|null
$tlsCertificateAuthorityPath  : string|null
$tlsClientCertificateFile  : string|null
$tlsClientCertificateKeyFile  : string|null
$tlsClientCertificateKeyPassphrase  : string|null
$tlsSelfSignedAllowed  : bool
$tlsVerifyPeer  : bool
$tlsVerifyPeerName  : bool
$useBlockingSocket  : bool
$username  : string|null
$useTls  : bool
getConnectTimeout()  : int
getDelayBetweenReconnectAttempts()  : int
getKeepAliveInterval()  : int
getLastWillMessage()  : string|null
getLastWillQualityOfService()  : int
getLastWillTopic()  : string|null
getMaxReconnectAttempts()  : int
getPassword()  : string|null
getResendTimeout()  : int
getSocketTimeout()  : int
getTlsCertificateAuthorityFile()  : string|null
getTlsCertificateAuthorityPath()  : string|null
getTlsClientCertificateFile()  : string|null
getTlsClientCertificateKeyFile()  : string|null
getTlsClientCertificateKeyPassphrase()  : string|null
getUsername()  : string|null
hasLastWill()  : bool
Determines whether the client has a last will.
isTlsSelfSignedAllowed()  : bool
setConnectTimeout()  : ConnectionSettings
The connect timeout is the maximum amount of seconds the client will try to establish a socket connection with the broker. The value cannot be less than 1 second.
setDelayBetweenReconnectAttempts()  : ConnectionSettings
Defines the delay between reconnect attempts in milliseconds.
setKeepAliveInterval()  : ConnectionSettings
The keep alive interval is the number of seconds the client will wait without sending a message until it sends a keep alive signal (ping) to the broker. The value cannot be less than 1 second and may not be higher than 65535 seconds. A reasonable value is 10 seconds (the default).
setLastWillMessage()  : ConnectionSettings
If the broker should publish a last will message in the name of the client when the client disconnects abruptly, this setting defines the message which will be published.
setLastWillQualityOfService()  : ConnectionSettings
The quality of service level the last will message of the client will be published with, if it gets triggered.
setLastWillTopic()  : ConnectionSettings
If the broker should publish a last will message in the name of the client when the client disconnects abruptly, this setting defines the topic on which the message will be published.
setMaxReconnectAttempts()  : ConnectionSettings
Defines the maximum number of reconnect attempts until the client gives up. This setting is only relevant if {@see setReconnectAutomatically()} is set to true.
setPassword()  : ConnectionSettings
The password used for authentication when connecting to the broker.
setReconnectAutomatically()  : ConnectionSettings
This flag determines whether the client will try to reconnect automatically, if it notices a disconnect while sending data.
setResendTimeout()  : ConnectionSettings
The resend timeout is the number of seconds the client will wait before sending a duplicate of pending messages without acknowledgement. The value cannot be less than 1 second.
setRetainLastWill()  : ConnectionSettings
This flag determines if the last will message of the client will be retained, if it gets triggered. Using this setting can be handy to signal that a client is offline by publishing a retained offline state in the last will and an online state as first message on connect.
setSocketTimeout()  : ConnectionSettings
The socket timeout is the maximum amount of idle time in seconds for the socket connection.
setTlsCertificateAuthorityFile()  : ConnectionSettings
The path to a Certificate Authority certificate which is used to verify the peer certificate, if TLS is used.
setTlsCertificateAuthorityPath()  : ConnectionSettings
The path to a directory containing Certificate Authority certificates which are used to verify the peer certificate, if TLS is used.
setTlsClientCertificateFile()  : ConnectionSettings
The path to a client certificate file used for authentication, if TLS is used.
setTlsClientCertificateKeyFile()  : ConnectionSettings
The path to a client certificate key file used for authentication, if TLS is used.
setTlsClientCertificateKeyPassphrase()  : ConnectionSettings
The passphrase used to decrypt the private key of the client certificate, which in return is used for authentication, if TLS is used.
setTlsSelfSignedAllowed()  : ConnectionSettings
This flag determines if self signed certificates of the peer should be accepted.
setTlsVerifyPeer()  : ConnectionSettings
This flag determines if the peer certificate is verified, if TLS is used.
setTlsVerifyPeerName()  : ConnectionSettings
This flag determines if the peer name is verified, if TLS is used.
setUsername()  : ConnectionSettings
The username used for authentication when connecting to the broker.
setUseTls()  : ConnectionSettings
This flag determines if TLS should be used for the connection. The port which is used to connect to the broker must support TLS connections.
shouldReconnectAutomatically()  : bool
shouldRetainLastWill()  : bool
shouldTlsVerifyPeer()  : bool
shouldTlsVerifyPeerName()  : bool
shouldUseBlockingSocket()  : bool
shouldUseTls()  : bool
useBlockingSocket()  : ConnectionSettings
Whether to use a blocking socket when publishing messages or not.

Properties

$tlsCertificateAuthorityFile

private string|null $tlsCertificateAuthorityFile = null

$tlsCertificateAuthorityPath

private string|null $tlsCertificateAuthorityPath = null

$tlsClientCertificateKeyFile

private string|null $tlsClientCertificateKeyFile = null

$tlsClientCertificateKeyPassphrase

private string|null $tlsClientCertificateKeyPassphrase = null

Methods

getDelayBetweenReconnectAttempts()

public getDelayBetweenReconnectAttempts() : int
Return values
int

getKeepAliveInterval()

public getKeepAliveInterval() : int
Return values
int

getLastWillMessage()

public getLastWillMessage() : string|null
Return values
string|null

getLastWillQualityOfService()

public getLastWillQualityOfService() : int
Return values
int

getLastWillTopic()

public getLastWillTopic() : string|null
Return values
string|null

getMaxReconnectAttempts()

public getMaxReconnectAttempts() : int
Return values
int

getTlsCertificateAuthorityFile()

public getTlsCertificateAuthorityFile() : string|null
Return values
string|null

getTlsCertificateAuthorityPath()

public getTlsCertificateAuthorityPath() : string|null
Return values
string|null

getTlsClientCertificateFile()

public getTlsClientCertificateFile() : string|null
Return values
string|null

getTlsClientCertificateKeyFile()

public getTlsClientCertificateKeyFile() : string|null
Return values
string|null

getTlsClientCertificateKeyPassphrase()

public getTlsClientCertificateKeyPassphrase() : string|null
Return values
string|null

hasLastWill()

Determines whether the client has a last will.

public hasLastWill() : bool
Return values
bool

isTlsSelfSignedAllowed()

public isTlsSelfSignedAllowed() : bool
Return values
bool

setConnectTimeout()

The connect timeout is the maximum amount of seconds the client will try to establish a socket connection with the broker. The value cannot be less than 1 second.

public setConnectTimeout(int $connectTimeout) : ConnectionSettings
Parameters
$connectTimeout : int
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setDelayBetweenReconnectAttempts()

Defines the delay between reconnect attempts in milliseconds.

public setDelayBetweenReconnectAttempts(int $delayBetweenReconnectAttempts) : ConnectionSettings

This setting is only relevant if setReconnectAutomatically() is set to true.

Parameters
$delayBetweenReconnectAttempts : int
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setKeepAliveInterval()

The keep alive interval is the number of seconds the client will wait without sending a message until it sends a keep alive signal (ping) to the broker. The value cannot be less than 1 second and may not be higher than 65535 seconds. A reasonable value is 10 seconds (the default).

public setKeepAliveInterval(int $keepAliveInterval) : ConnectionSettings
Parameters
$keepAliveInterval : int
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setLastWillMessage()

If the broker should publish a last will message in the name of the client when the client disconnects abruptly, this setting defines the message which will be published.

public setLastWillMessage(string|null $lastWillMessage) : ConnectionSettings

A last will message will only be published if both this setting as well as the last will topic are configured.

Parameters
$lastWillMessage : string|null
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setLastWillQualityOfService()

The quality of service level the last will message of the client will be published with, if it gets triggered.

public setLastWillQualityOfService(int $lastWillQualityOfService) : ConnectionSettings
Parameters
$lastWillQualityOfService : int
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setLastWillTopic()

If the broker should publish a last will message in the name of the client when the client disconnects abruptly, this setting defines the topic on which the message will be published.

public setLastWillTopic(string|null $lastWillTopic) : ConnectionSettings

A last will message will only be published if both this setting as well as the last will message are configured.

Parameters
$lastWillTopic : string|null
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setMaxReconnectAttempts()

Defines the maximum number of reconnect attempts until the client gives up. This setting is only relevant if {@see setReconnectAutomatically()} is set to true.

public setMaxReconnectAttempts(int $maxReconnectAttempts) : ConnectionSettings
Parameters
$maxReconnectAttempts : int
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setPassword()

The password used for authentication when connecting to the broker.

public setPassword(string|null $password) : ConnectionSettings
Parameters
$password : string|null
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setReconnectAutomatically()

This flag determines whether the client will try to reconnect automatically, if it notices a disconnect while sending data.

public setReconnectAutomatically(bool $reconnectAutomatically) : ConnectionSettings

The setting cannot be used together with the clean session flag.

Parameters
$reconnectAutomatically : bool
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setResendTimeout()

The resend timeout is the number of seconds the client will wait before sending a duplicate of pending messages without acknowledgement. The value cannot be less than 1 second.

public setResendTimeout(int $resendTimeout) : ConnectionSettings
Parameters
$resendTimeout : int
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setRetainLastWill()

This flag determines if the last will message of the client will be retained, if it gets triggered. Using this setting can be handy to signal that a client is offline by publishing a retained offline state in the last will and an online state as first message on connect.

public setRetainLastWill(bool $lastWillRetain) : ConnectionSettings
Parameters
$lastWillRetain : bool
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setSocketTimeout()

The socket timeout is the maximum amount of idle time in seconds for the socket connection.

public setSocketTimeout(int $socketTimeout) : ConnectionSettings

If no data is read or sent for the given amount of seconds, the socket will be closed. The value cannot be less than 1 second.

Parameters
$socketTimeout : int
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setTlsCertificateAuthorityFile()

The path to a Certificate Authority certificate which is used to verify the peer certificate, if TLS is used.

public setTlsCertificateAuthorityFile(string|null $tlsCertificateAuthorityFile) : ConnectionSettings
Parameters
$tlsCertificateAuthorityFile : string|null
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setTlsCertificateAuthorityPath()

The path to a directory containing Certificate Authority certificates which are used to verify the peer certificate, if TLS is used.

public setTlsCertificateAuthorityPath(string|null $tlsCertificateAuthorityPath) : ConnectionSettings

Certificate files in this directory must be named by the hash of the certificate, ending with ".0" (without quotes). The certificate hash can be retrieved using the openssl_x509_parse() function, which returns an array. The hash can be found in the array under the key "hash".

Parameters
$tlsCertificateAuthorityPath : string|null
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setTlsClientCertificateFile()

The path to a client certificate file used for authentication, if TLS is used.

public setTlsClientCertificateFile(string|null $tlsClientCertificateFile) : ConnectionSettings

The client certificate must be PEM encoded. It may optionally contain the certificate chain of issuers. The certificate key can be included in this certificate file or in a separate file (ConnectionSettings::setTlsClientCertificateKeyFile()). A passphrase can be configured using ConnectionSettings::setTlsClientCertificateKeyPassphrase().

Parameters
$tlsClientCertificateFile : string|null
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setTlsClientCertificateKeyPassphrase()

The passphrase used to decrypt the private key of the client certificate, which in return is used for authentication, if TLS is used.

public setTlsClientCertificateKeyPassphrase(string|null $tlsClientCertificateKeyPassphrase) : ConnectionSettings

This option requires ConnectionSettings::setTlsClientCertificateFile() and ConnectionSettings::setTlsClientCertificateKeyFile() to be used as well.

Please be aware that your passphrase is not stored in secure memory when using this option.

Parameters
$tlsClientCertificateKeyPassphrase : string|null
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setTlsSelfSignedAllowed()

This flag determines if self signed certificates of the peer should be accepted.

public setTlsSelfSignedAllowed(bool $tlsSelfSignedAllowed) : ConnectionSettings

Setting this to TRUE implies a security risk and should be avoided for production scenarios and public services.

Parameters
$tlsSelfSignedAllowed : bool
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setTlsVerifyPeer()

This flag determines if the peer certificate is verified, if TLS is used.

public setTlsVerifyPeer(bool $tlsVerifyPeer) : ConnectionSettings
Parameters
$tlsVerifyPeer : bool
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setTlsVerifyPeerName()

This flag determines if the peer name is verified, if TLS is used.

public setTlsVerifyPeerName(bool $tlsVerifyPeerName) : ConnectionSettings
Parameters
$tlsVerifyPeerName : bool
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setUsername()

The username used for authentication when connecting to the broker.

public setUsername(string|null $username) : ConnectionSettings
Parameters
$username : string|null
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

setUseTls()

This flag determines if TLS should be used for the connection. The port which is used to connect to the broker must support TLS connections.

public setUseTls(bool $useTls) : ConnectionSettings
Parameters
$useTls : bool
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

shouldReconnectAutomatically()

public shouldReconnectAutomatically() : bool
Return values
bool

shouldRetainLastWill()

public shouldRetainLastWill() : bool
Return values
bool

shouldTlsVerifyPeer()

public shouldTlsVerifyPeer() : bool
Return values
bool

shouldTlsVerifyPeerName()

public shouldTlsVerifyPeerName() : bool
Return values
bool

shouldUseBlockingSocket()

public shouldUseBlockingSocket() : bool
Return values
bool

useBlockingSocket()

Whether to use a blocking socket when publishing messages or not.

public useBlockingSocket(bool $useBlockingSocket) : ConnectionSettings

Normally, this setting can be ignored. When publishing large messages with multiple kilobytes in size, a blocking socket may be required if the receipt buffer of the broker is not large enough.

Note: This setting has no effect on subscriptions, only on the publishing of messages.

Parameters
$useBlockingSocket : bool
Return values
ConnectionSettings

A copy of the original object with the new setting applied.

Search results