AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Comunicación / Funciones MQTTT
  • Properties specific to mqttSession variables
  • Authentication mode
  • Functions that use mqttSession variables
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
mqttSession (Variable type)
 
The mqttSession type is used to define the parameters for connecting to the MQTT broker. These connection parameters can be defined and changed by several WLanguage properties.
Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Ejemplo
// Declare the MQTT connection
gMqttSession is mqttSession

// Retrieve the data typed in the connection window
gMqttSession.Address = EDT_Broker_Address
gMqttSession.Port = EDT_Port
gMqttSession.Option = CBOX_SSL
gMqttSession.ConnectionTimeout = EDT_Connection_Timeout
gMqttSession.User = EDT_Login
gMqttSession.UserPassword = EDT_PSW
gMqttSession.PrivateKey = EDT_Private_Key
gMqttSession.PrivateKeyPassword = EDT_Private_Key_PSW
gMqttSession.ClientID = EDT_ClientID
gMqttSession.CleanSession = CBOX_Clean_Session
IF MQTTConnect(gMqttSession) THEN
	Message("Connection OK")
ELSE
	Error("Connection problem. '" + ErrorInfo() + "')")
END
Propiedades

Properties specific to mqttSession variables

The following properties can be used to handle a MQTT session:
Property nameType usedEffect
AddressCharacter stringAddress of MQTT server (also called "MQTT broker"). This address can be specified as follows:
  • IP address in XXX.XXX.XXX.XXX format (125.5.110.100 for example).
  • IP address containing the server name (MQTTServer for example). This syntax is recommended.
CleanSessionBoolean
  • True if it is necessary to empty the generic global parameters on the server,
  • False otherwise.
ClientIDCharacter stringClient identifier. This property must not be left empty.
ConnectionTimeoutInteger or DurationConnection timeout in seconds. This property can correspond to:
  • an integer corresponding to the number of seconds,
  • a Duration variable,
  • the duration in a readable format (e.g., 10 s).
IgnoreErrorInteger constantSpecifies the ignored errors. Corresponds to a constant or to a combination of constants:
  • mqttIgnoreCertificateExpired The certificate date is ignored.
  • mqttIgnoreCertificateInvalid The certificate is ignored.
  • mqttIgnoreCertificateNameInvalid: The site name in the certificate is ignored.
  • mqttIgnoreRevocation: Certificate revocation is ignored.
OptionInteger constantConnection options. This property can correspond to the optionSSL constant for an SSL connection.
PortIntegerPort of MQTT server. This port correspondsn to 1883 by default (or 8883 for an SSL connection).
PrivateKeyCharacter string or Certificate variableName of the Certificate variable or path of the pem file (to make a private key connection).
If this property is set, authentication by key is performed: only the properties User, PrivateKey and PrivateKeyPassword are taken into account..
PrivateKeyPasswordCharacter string or Secret stringPassword of the key file (for a private-key based authentication). The PrivateKey property corresponds to the private key to be used.
Novedad versión 2025
Cadenas secretas: Si utiliza el almacén de cadenas secretas, el tipo de cadena secreta utilizado para este parámetro debe ser "ANSI string - Latin".
Para obtener más información sobre las cadenas secretas y el almacén, consulte Almacén de cadenas secretas.
UserCharacter stringUsername.
UserPasswordCharacter string or Secret stringUser password (the User property corresponds to the user's name).
Novedad versión 2025
Cadenas secretas: Si utiliza el almacén de cadenas secretas, el tipo de cadena secreta utilizado para este parámetro debe ser "ANSI o Unicode string".
Para obtener más información sobre las cadenas secretas y el almacén, consulte Almacén de cadenas secretas.
Observaciones

Authentication mode

Key-based authentication takes precedence over password-based authentication.
Key-based authentication is used if:
  • the server supports this authentication mode.
  • the PrivateKey property is specified.
Password-based authentication is used if:
  • the server supports this authentication mode.
  • property UserPassword is set.

Functions that use mqttSession variables

Functions manipulating variables of type mqttSession are as follows:
MQTTConnectSe utiliza para conectarse a un servidor MQTT (también llamado "Broker").
MQTTDisconnectPermite desconectarse de un servidor MQTT (también llamado "Broker").
MQTTPublishPublishes a message on the MQTT broker.
MQTTSubscribeUsed to subscribe to a MQTT notification.
MQTTUnsubscribeSe utiliza para darse de baja de una notificación MQTT.
MQTTUnsubscribeAllPermite darse de baja de todas las suscripciones existentes.
Ver también
Versión mínima requerida
  • Versión 22
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 16/05/2025

Señalar un error o enviar una sugerencia | Ayuda local