MQTT integration

Hi C3 Community!
Do you know if we can integrate data in the platform (7.8) from a MQTT broker which isn’t AWS IoT ?
I found the type MqttPubSubClient, can you please give a generic example on how to use it ?

Thank you !

Did you check the documentation page for MQTT setup, the url should be something like

Basically to setup , you need to:

  1. Acquire the certificate for MQTT communication. This certificate is generally distributed by the MQTT server.
  2. Build up MqttAuth by using the certificate.
  3. Establish MqttPubSubClient through MqttAuth
  4. Use MqttPubSubClient to communicate with Mqtt server for publishing, subscribing

Hey Bachir,
Thank you very much, I saw the doc but I was wondering if it worked only for AwsIotThing or for all types of MQTT brokers. I’ll try when my customer’s MQTT broker will be operational.

I think the example talk about AwsIotThing just as an example on how to get a certificate as the rest has nothing to do with AWS IoT.
I believe you should be able to use another broker along its certificate and do the MQTT specific staff starting from step 2.

I did some testing recently but it seems that it is only working for AWS IoT (when I look at c3 server code, they use by default the RootCA of AWS). My customer is currently using a MQTT broker using port 8883 with SSLv3 and a username and password and the type MQTTauth does not seem to be made for this kind of auth.

Moreover, I got some issues, even testing with AWS IoT without creating a thing like in the tutorial, but just getting the privateKey and client certificate of an AWS IoT “thing” from my personal account.

I’m basically doing it like that :
var auth = MqttAuth.make({clientId:'test', brokerUrl: brokerUrl, privateKey:privatekey, certificatePEM: cert});
var client = MqttPubSubClient.createClient(auth);

with var brokerUrl = 'ssl://{myAWSIoTEndpoint}:8884'
var cert: my client certificate and var privatekey : my client private key.

And I got this error :
I got "Error: MqttSubPubClient constructor failed. Action=setSocketFactory failed, Error=java.lang.ClassCastException: org.bouncycastle.openssl.PEMKeyPair cannot be cast to org.bouncycastle.cert.X509CertificateHolder