Hello everyone.
I can't connect to Hivemq.
If I connect to the local server everything works.
If I connect with the hivemq cloud credentials the error is thrown:
(MqttSecurityException) Not authorized to connect (5)
Credentials are right and working from hivemq client.
Where am I wrong?
Thank you all.
I can't connect to Hivemq.
If I connect to the local server everything works.
If I connect with the hivemq cloud credentials the error is thrown:
(MqttSecurityException) Not authorized to connect (5)
Credentials are right and working from hivemq client.
Where am I wrong?
Thank you all.
MQTT:
Sub Process_Globals
Private mqtt As MqttClient
Private mytopic As String
Private serializator As B4XSerializator
Private serverURI As String = "tcp://192.168.1.15:1883"
Private user As String = "admin"
Private pass As String = "Password"
' Private serverURI As String = "ssl://adbeffbd072848c190f7afdad3301f45.s2.eu.hivemq.cloud:8883"
' Private user As String = "device"
' Private pass As String = "password"
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
mqtt.Initialize("mqtt", serverURI, Rnd(0, 999999999) & DateTime.Now)
Dim mo As MqttConnectOptions
mo.Initialize(user, pass)
mqtt.Connect2(mo)
mytopic = "update/memo" & mqtt.ClientId
End If
Activity.LoadLayout("1")
Canvas1.Initialize(Activity)
End Sub
Sub mqtt_Connected (Success As Boolean)
If Success = False Then
Log(LastException)
lblStatus.Text = "Errore connessione"
Else
lblStatus.Text = "Connesso"
mqtt.Subscribe(mytopic, 0)
End If
End Sub
End Sub