Connect local Mosquitto MQTT broker to Google Cloud IoT

3.5k Views Asked by At

In my current setup i read data using ebusd from my heating system which works perfectly fine. In the next step i'd like to send this data to a Google IoT Core Device. Unfortunately ebusd does not support setting the clientid externally.

To circumvent this i installed a local Mosquitto Broker which accepts unsecured messages in my Raspberry Pi and shall bridge them to the Google IoT Core Broker. Here is how i configured my local Mosquitto Broker:

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_type all
log_dest file /var/log/mosquitto/mosquitto.log

# Goolge IoT Core Configuration

connection bridge-to-gcp

address mqtt.googleapis.com:8883

bridge_attempt_unsubscribe false
bridge_certfile /home/pi/certificates/rsa_cert.pem
bridge_keyfile /home/pi/certificates/rsa_private.pem
bridge_cafile /home/pi/certificates/roots.pem
bridge_protocol_version mqttv311
bridge_insecure false

tls_version tlsv1.2
try_private true

start_type automatic
cleansession true
notifications false

local_clientid local-to-remote-gcp-bridge

remote_username unused
remote_password <JWT Token generated using jwt.io>
remote_clientid projects/project-251313/locations/europe-west1/registries/prot/devices/ebusd12345

topic # both

include_dir /etc/mosquitto/conf.d

Although this setup works with AWS IoT with Google Cloud IoT i get

1542622526: Connecting bridge bridge-to-gcp (mqtt.googleapis.com:8883)
1542622526: Bridge projects/project-251313/locations/europe-west1/registries/prot/devices/ebusd12345 sending CONNECT
1542622526: Socket error on client local.projects/project-251313/locations/europe-west1/registries/prot/devices/ebusd12345, disconnecting.

After googling some time i found this blog (see http://community.onion.io/topic/2858/omega-onion-connecting-to-cloud-cloud-iot/2) which states that Google Cloud IoT Core does not support connections by "sub-brokers" but i didn't find a second statement claiming the same.

Can anybody either confirm that i am trying to do something impossible or please help with with configuring the broker properly?

1

There are 1 best solutions below

2
On

I reached out to the author of that blog and other people who work on Cloud IoT Core and unfortunately it seems like MQTT bridging indeed is currently not supported. In the meantime, it seems like you're in contact with the ebusd owner on Github to add a configurable clientid feature, which would be a good temporary fix.

With that said, we have a feature that will be going into beta soon that will help you address this kind of issue specifically, so stay tuned!