Connect
This method initiates a connection between the MQTT broker (MQTT server) and client, and sets the timeout value for the client. If the connection is established, this returns a true value. If no connection was made, a false value is returned. A connection will disconnect automatically if the timeout period is exceeded.
Group: MQTT Object
Syntax: oMQTT.Connect(ServerAddress, ClientId, Timeout) as Boolean
ServerAddress (String) the tcp IP address or name of the MQTT broker
ClientId (String) the name of the client
Timeout (Long) the time in seconds a client waits before the connection is closed
bOK (Boolean) True means there is already a connection; False means there isn’t a connection.
Example:
Dim WithEvents moClient As New MQTT
Private Sub Form_Load()
On Error Resume Next
App.Balloon("Connecting...", -1)
If Not moClient.Connect("tcp://localhost:1883", "RFgen_Publisher_Client_001", 4000)
Then
App.MsgBox("Error: " & moClient.Error)
Exit Sub
End If
App.Balloon("", 0)
End Sub
Versions Supported: RFgen 5.1.3 and newer.