IBM cloud refuses mqtt.connect()


#1

Hello everyone.

I am working on my final project for my master degree with hexiwear and Zerynth. I use ublox sara g350 to connect it with the cloud and I made it work with Wolkabout, but I need it to connect with Ibm Cloud in order to use Python sdk for Watson AI on the collected data.

I used the example in the documentation changing the credentials(I tested them before with an online mqtt client) in the json file but I get an exception when It calls iot.mqtt.connect.

After reading another post in a thread about AWS cloud about a similar issue, I think that the cloud is refusing the connection because I am missing something about TLS protocol.
I found videos about using ztc for AWS cloud and openssl for Google Cloud to generate certificates but not for Watson.

What am I missing? Any help?

Thanks.


#2

Hi @cesar_zer,

what exception are you getting? IBM Cloud IoT only requires TLS v1.2 (supported by sara g350) and the auth token, no particular certificates are needed.

Let me know :slight_smile:


#3

Hi LorenzoR,

When the example code tries to connect in the line “device.mqtt.connect()” It doesn`t and I capture this error:

   IOError  at line 36 of ibmcloud.iot.iot.connect
   raised at line 393 of mqtt.mqtt.connect
   raised at line 446 of mqtt.mqtt._connect
   raised at line 145 of socket.connect

By clicking on it in the serial monitor it sends me to the 36 line in iot.py

    mqtt.Client.connect(self, self.endpoint, 60, port=port, ssl_ctx=self.ssl_ctx)

I changed de json file with my device (tested) credentials and include the code necessary for the Sara g350. As I said it in my first post it worked with Wolkabout so I don’t get what is wrong.

What can it be?

Thank you!


#4

Hi @cesar_zer,

I found the issue: please open ZERYNTH_INSTALLATION/dist/r2.1.2/libs/official/ublox/g350/csrc/g350.c, line 2386, replace

if(_gs_tls_config(1,1,NULL,0)) goto exit;

with

if(_gs_tls_config(1,3,NULL,0)) goto exit;

to set TLS version to TLSv1.2: unfortunately the modem seems not to require a minimum version to support, but exactly the version you want to use.

Let me know :slight_smile:


#5

Hi @LorenzoR.

It works!!!

Thank you.