Android Question MQTT client question

DickD

Active Member
Licensed User
I'm trying to use the MQTT client and I'm looking at the MQTT_chat sample program. This confuses me since it seems to include components of both the client and the broker. I plan on only using the client as I have signed up for a CloudMQTT broker test ID.

Do I also need to install the broker library if I only want to use the client? Does someone have a sample app with just the client only? Combining both is really, really confusing.

Also I don't understand the line shown below which doesn't make any sense to me. Can't I just put the name of the mqtt server ("m11cloudmqtt.com") as the second parameter and my username as the third?

B4X:
 client.Initialize("client", $"tcp://${Host}:${port}"$, "android" & Rnd(1, 10000000))
 

DonManfred

Expert
Licensed User
Longtime User
Think over what the third parameter is doing. Answer the question by yourself if you just can use your username instead.
 
Upvote 0

DickD

Active Member
Licensed User
I'm trying to use the MQTT client and I'm looking at the MQTT_chat sample program. This confuses me since it seems to include components of both the client and the broker. I plan on only using the client as I have signed up for a CloudMQTT broker test ID.

Do I also need to install the broker library if I only want to use the client? Does someone have a sample app with just the client only? Combining both is really, really confusing.

Also I don't understand the line shown below which doesn't make any sense to me. Can't I just put the name of the mqtt server ("m11cloudmqtt.com") as the second parameter and my username as the third?

B4X:
client.Initialize("client", $"tcp://${Host}:${port}"$, "android" & Rnd(1, 10000000))
Think over what the third parameter is doing. Answer the question by yourself if you just can use your username instead.
I'm pretty new to mqtt having only just discovered it yesterday. I've read the Cloud.com docs from beginning to end but they don't address anything specific to a particular client like B4A. I haven't found any documentation on the B4X forums other than the sample mentioned.

Maybe the 3rd param is a unique (random) message or user identifier??? I guess I'll just have to experiment to find out.
 
Upvote 0

DickD

Active Member
Licensed User
Upvote 0

DickD

Active Member
Licensed User
No. It´s NOT NEEDED. A ClientID is like a unique username.
The bottom line for me is that a picture is worth a thousand words. People learn best by example. A sample program that does not include any extraneous or unrelated topics always works best. Once I understand how this works I will write up my own sample program with lots of comments that makes it all clear and file it away for later use. Take it from someone who has taught programming and other CS courses at a large state university for 15 years. I understand how people learn.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi @DickD ,
if it may help you, I have got an old test app (june 2016) I did connecting to CloudMQTT where only the client code was used.
Just PM me if you think that could help as a starting point of your project.
Just a note of caution: I recall nothing about that test..eheh
 
Upvote 0

DickD

Active Member
Licensed User
Hi @DickD ,
if it may help you, I have got an old test app (june 2016) I did connecting to CloudMQTT where only the client code was used.
Just PM me if you think that could help as a starting point of your project.
Just a note of caution: I recall nothing about that test..eheh
Yes, I'd like to see that but.... (dumb question) what is PM & how?
 
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
@DickD: Look for the sample MQTTCanvas; it's a client only example. The third parameter cliendId is not always needed, you can see, that erel
sometimes use a random value for it. To log in in your server you have to use MqttConnectOptions; you intitalize them with username and password,
than you can connect.
 
Upvote 0

DickD

Active Member
Licensed User
@DickD: Look for the sample MQTTCanvas; it's a client only example. The third parameter cliendId is not always needed, you can see, that erel
sometimes use a random value for it. To log in in your server you have to use MqttConnectOptions; you intitalize them with username and password,
than you can connect.
Searching on MQTTCanvas doesn't find a match except for 2 postings about not being able to compile that program. Maybe it's been removed???
 
Upvote 0
Top