MQTT client that works with Google IOT cloud

Hello

We are today using paho and this MQTT wrapper: https://github.com/mangOH/MqttClient/tree/use_paho_linux_version developed by @dfrey and others to connect to our own mosquitto broker with TLS encryption.

But I’m now trying to connect to google’s mqtt bridge with TLS and JWT. But I get a socket error when trying to connect. Not sure how to investigate this further but I think this may be a clue?

Is there a known issue connecting to gcloud with sierra (WP85) and this wrapper or have someone made it work?

Hi @nilsarve,
If you are still looking for a solution, you could try this option: https://github.com/nhonchu/mqttClient-for-Legato

Hope this helps

Looks great. Will check it out. :grinning:

Hi @NhonChu,
Did some testing today but could not connect to Google cloud platform.

First of all is there a type here?
image
Had to make it

openssl genrsa -out rsa_private.pem 2048

for google to accept my public key.

But when running

gmqtt session start
i get Failed:

Any help would be greatly appreciated!

Hi @nilsarve,

Thank you for reporting the typo (2048 instead of 2018) for the key generation.

Your device passed the SSL authentication steps, however for some reason the server rejects your mqtt connection request. Could you check these points :

  • is the device communication has been allowed ?
    image

  • have you uploaded the public key certificate to Google IoT Core ? And have the app to selected the private key?

Nhon

Did not build a system image but used the path option. Maybe I should try building a system image?

Thanks for the info.
You don’t need to build a system image, just the app.
I’ll try on WP85 and will let you know.

Hi @nilsarve,
I found the issue (side effect of memory optimization). It has been fixed, please retrieve the new mqttGeneric.h file and recompile all components.
Let me know if this solves your connection issue.
Thanks

Thanks @NhonChu!
That solved it! :smiley:

Hi @nilsarve,
Great :ok_hand::grinning:
Thank you for reporting this.

@nilsarve How is this MQTT with Google IOT Cloud working for you? Did you notice any changes in your data costs not having to deal with the LWM2M registration?

Thanks

@NhonChu How do I go about ensuring the private key will be persisted across FOTA?

Thanks,
Darren

@dbeckwith The google cloud solution consumed alot of data as the overhead is a bit rich so we send our data to a mosquitto broker and forward data to google iot cloud from our server.

@nilsarve Any idea as to why there is so much overhead with the Google Cloud IoT vs Mosquitto? Are both solutions using TLS?

Yes both solutions use TLS but google uses a long topic name but on top of that I have measured 403 bytes of overhead on every publish while I have measured this to 225 bytes on every publish to my mosquitto broker.

Might not sound like much but if you publish like every other minute every day 24/7 then you have alot of data. If you send big payloads but not so often it might not be a big issue.

@nilsarve How do you go about saving your TLS certificate so that it persists across rollbacks or app/Legato updates?

If just bundle the certificates with my app and that works great for me.

bundles:
 {
    file:
    {
        certs         / 
    }
 }

@nilsarve Thank you for the example. I feel I’m still missing something on my part. Isn’t the certificates file device specific? If so how do you do produce units if the the certificates file is part of the build?

If you use the same certificate on all clients this will work but if you want to have a uniqe certificate then maybe you could use the config tree to store the certificate?

Hi i facing issue with the sample code which is mentioned in above messages, I am able to send data to iot.eclipse.org but receiving is not happening,

SubAck is receiving for the subscribed topic, Receive handler is assigned properly,

Can you pls suggest a solution for this issue