[solved] Mqtt over internet? aka: "How to set up cloudMQTT bridge with Hassio mosquitto broker"

That should not be an issue as the bridge is being setup in MosQuiTTo not on CloudMQTT.

I use the free plan on CloudMQTT also.

I know this is the basics and you have likely checked, but did you check the server address and port number?
I know I messed up and put m11.cloudmqtt.com instead of my actual server the first time.
I should know better than to do it on a mobile device :slight_smile:

yes i have checked that if iā€™m not wrong i have to create a new user in my cloudmqtt and use that user name and password in hassio mqttconfig file? and i used port from cloudmqtt not ssl port or websockets portā€¦

this is how my config file looks

connection cloudmqtt

address xxx.cloudmqtt.com:xxxxx
remote_username xxxx
remote_password xxxx
clientid rgtegerhsgtjtegggshtukk
try_private false
start_type automatic
topic # in
topic +/remote_cloudmqtt/# out

That looks about right. I donā€™t use an out on mine as I only use it for OwnTracks at the moment.
This is my conf file

connection cloudmqtt
address xxxx.cloudmqtt.com:xxxxx
remote_username xxxx
remote_password xxxxx
clientid xxxxxx
try_private false
start_type automatic
topic owntracks/# in

I setup a brand new user in Users and ACL section of CloudMQTT for the bridge.

I am stuck as to why you have auth issues now :confused:

this is how my cloudmqtt log looks like

2018-09-18 08:47:58: New connection from 51.xxx .190.xxx on port xxxx.
2018-09-18 08:48:29: New connection from 51.xxx .190.xxx on port xxxx.
2018-09-18 08:49:04: New connection from 51.xxx .190.xxx on port xxxx.
2018-09-18 08:49:40: New connection from 51.xxx .190.xxx on port xxxx.

i donā€™t know what else to try

Have you used a MQTT client like MQTTfx or something similar to see whether topics from CloudMQTT are hitting your Mosquitto server?

Also, if you are using HASSIO (as I am) your ā€œConfigā€ file in the plugin section should look similar to this:

{
  "plain": true,
  "plain_websockets": false,
  "ssl": false,
  "ssl_websockets": false,
  "anonymous": true,
  "logins": [],
  "customize": {
    "active": true,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

I use anonymous login for the local MosQuiTTo Broker, but it can be setup with local users as well.

The other config, as pasted earlier, is in the \\hassio\share\mosquitto\cloudmqtt.conf file.

I will be honest, I am running out of ideas as well. Maybe try copy and paste to copy your password set in your conf file into CloudMQTT so it is absolutely certain it is identical, other than that I am a bit lost now

1 Like

i found my problem there was space after my passwordā€¦ i had opened conf file in notepad and found this silly mistakeā€¦ thank you so much :slight_smile:

1 Like

@ashfaaaa

Glad it is all working now. I have found it to be very reliable, and means I can keep my cloud based trackers and my internal MQTT stuff isolated enough and not need port forwarding.

1 Like

thanks, same here! Saved my day! (or at least afternoon!)

1 Like

Do you use an SSL connection for cloudmqtt?

Thanks.

I donā€™t think I did (looking at my code try_private is set to false).
I removed it from my configuration a while back as I use remote_home_assistant now.
But Iā€™m guessing the try_private would be the way to try it.

Could you explain what that remote_home_assistant thing is, please?

Itā€™s a little different in the sense that you connect two different home assistant machines. One acts as a slave and all its entities are passed to a master HA.

So you will need an extra RPi or a device that can run HA on the remote location.

Github project is here:

Iā€™ve tried setting up everything as above, but every time it tries to connect to Cloudmqtt i get:

1563722719: Socket error on client , disconnecting.

any thoughts? doesnā€™t seem to matter what port i use, nothings connecting

Iā€™m going to try these steps in the coming days, will report back on how I progress.

Hi @ct36 Did you end up resolving this?

I have the same issue.

@ct36 & @Zpeed, Iā€™ve managed to get it working by following this thread MQTT: Working Mosquitto / CloudMQTT Bridge

Essentially you must use this config which directs mqtt to use a pre-existing ā€œca-certificates.crtā€ file in Home Assistant. The mosquitto.conf file is as below which will bridge all in and outbound topics on both brokers:

connection couldmqtt
address <your cloudmqtt account:port>
topic # both
try_private true
notifications false
start_type automatic
remote_clientid <your client id>
remote_username <your user name>
remote_password <your password>
keepalive_interval 300
cleansession true
bridge_protocol_version mqttv311
local_clientid hass
bridge_cafile /etc/ssl/certs/ca-certificates.crt
bridge_insecure false

You can be more specific on the topics you expose by using the ā€œinā€ and ā€œoutā€ syntax:

topic subject1 in
topic subject2 in
topic subject3 out
topic subject4 out
topic subject5 both
1 Like

Hey, I did get this working eventually, it turned out I was creating the .conf file in the wrong location.

connection cloudmqtt
address server:port
remote_username user
remote_password password
clientid account from users & acl
try_private false
start_type automatic
topic # in

as for the rest, just make sure most of the details are from your server instance front mage, and the clientid from the Users & ACL section