Android Question MQTT Chat with Auto Discovery

postasat

Active Member
Licensed User
Longtime User
Hi,
I would like to use "MQTT Chat with Auto Discovery" with internet cloud service.
I tried with the free service on https://www.maqiatto.com with the following code:

B4X:
    client.Initialize("client", "tcp://maqiatto.com:8883", "android" & Rnd(1, 10000000))
    Dim mo As MqttConnectOptions
    mo.Initialize("my username", "my password")
    client.Connect2(mo)

but I have a connection error (success=false):
"Error connecting: (MqttException) Unexpected error (6)"

How can I solve it ?

Do you know a simple way to connect to a free MQTT cloud service ?

Thank you.
 

barx

Well-Known Member
Licensed User
Longtime User
I believe the use of port 8883 is default for secure connections. Try changing
B4X:
"tcp://maqiatto.com:8883"
to
B4X:
"ssl://maqiatto.com:8883"
 
Upvote 0

postasat

Active Member
Licensed User
Longtime User
Hi,
the correct code is with port 1883.

B4X:
client.Initialize("client", "tcp://maqiatto.com:1883", "android" & Rnd(1, 10000000))
    Dim mo As MqttConnectOptions
    mo.Initialize("my username", "my password")
    client.Connect2(mo)

Now I can connect, but when I push "start server", the code doesn't open chat page.
And if I start another phone as client, the button "Connect As Client" remains disabled.
Maybe the autodiscovery function is not made for mqtt cloud server ?
 
Upvote 0
Top