Subscribing to MQTT

53 views
Skip to first unread message

Miriam Caisse

unread,
Apr 26, 2021, 3:43:51 PM4/26/21
to MQTT
Hello everyone, 

I am trying to connect to my GCP instance using MQTT to send messages.

Here are the steps I have completed so far:

  Creating the Instance (from choosing the boot dick to making an SSH Key)
  Connecting to said instance using PuTTY (successfully so)
  Installing the broker (mosquitto)

Everything that I have done so far has worked properly. My question now is about how to subscribe to a topic.

mosquitto_sub -d -h [host] -u [username] -t [Random topic name]

What is the host? Our external IP, Internal IP  or our Service Account? 
In the first and second situations, I haven't managed to connect. In the third, I got a "Lookup error"

For the username, I have no idea what it's supposed to be so I haven't used it (maybe this is where my mistake is). It could be the name of the Key I made, the name of the Instance, or something else entirely. I really can't find it anywhere.

If anyone can clarify those problems, it would be great!

Cheers,
Miriam Caisse


Greg Troxel

unread,
Apr 26, 2021, 5:32:22 PM4/26/21
to Miriam Caisse, MQTT

The host is a name to be looked up in DNS that will resolve to an IP
address where the broker is running, or an IP address. Issues about
internal/external are GCP issues, not mosquitto issues. Likely you use
the same thing you used with putty.

You need to start the broker, not just install it.

The broker by default, in recent versions, does not listen to non-local
addresses. You will need to read the man page and configure that.

usernames/passwords are within the MQTT protocol and are configure in
the mosquitto config file, or rather in users/acl file pointed to by
that.

You must ensure that there are no firewalls blocking access to your
broker.

I would suggest setting up mosuqitto on a spare machine on your local
LAN, which will cause you to work through a lot of the above, and then
try again on GCP.


signature.asc
Reply all
Reply to author
Forward
0 new messages