C++ mosquitto client with TLS

735 views Asked by At

I am creating a C++ MQTT client which use mosquitto Libraries and mosquittopp.h :

Git Repository

I am trying to connect the client C++ to the broker but i got this error:

1646918108: Client <unknown> disconnected: Protocol error.
1646918614: New connection from 13.38.126.191:60346 on port 9001.
1646918614: OpenSSL Error[0]: error:1404A42E:SSL routines:ST_ACCEPT:tlsv1 alert protocol version

However, when i try to connect a NodeJs client with TLS i have succeeded :

1646918793: New connection from 13.38.126.191:60366 on port 9001.
1646918793: New client connected from 13.38.126.191:60366 as nodeJs (p2, c1, k60, u'client2').

So when i analyse the difference between the two clients, i recognize that is a problem with the protocol because in the Node client when i define the host of the broker like below :

var client = mqtt.connect("mqtts://mosquitto.ac-video.com:9001",options);

But in the c++ Client i did not know how to put the protocol with the host:

const char* host="mosquitto.ac-video.com";

Any suggestion please .

0

There are 0 answers