MyQttConn * myqtt_tls_conn_new ( MyQttCtx ctx,
const char *  client_identifier,
axl_bool  clean_session,
int  keep_alive,
const char *  host,
const char *  port,
MyQttConnOpts opts,
MyQttConnNew  on_connected,
axlPointer  user_data 
)

Allows to create a new MQTT connection a MQTT broker/server securing first the connection with TLS (MQTT over TLS).

Please, see myqtt_conn_new for more notes. You must call myqtt_tls_init first before creating any connection.

Parameters
ctxThe context where the operation will take place.
client_identifierThe client identifier that uniquely identifies this MQTT client from others. It can be NULL to let MQTT 3.1.1 servers to assign a default client identifier BUT clean_session must be set to axl_true. This is done automatically by the library (setting clean_session to axl_true when NULL is provided).
clean_sessionFlag to clean client session or to reuse the existing one. If set to axl_false, you must provide a valid client_identifier (otherwise the function will fail).
keep_aliveKeep alive configuration in seconds after which the server/broker will close the connection if it doesn't detect any activity. Setting 0 will disable keep alive mechanism.
hostThe location of the MQTT server/broker
portThe port of the MQTT server/broker
optsOptional connection options. See myqtt_conn_opts_new
on_connectedAsync notification handler that will be called once the connection fails or it is completed. In the case this handler is configured the caller will not be blocked. In the case this parameter is NULL, the caller will be blocked until the connection completes or fails.
user_dataUser defined pointer that will be passed to the on_connected handler (in case it is defined).
Returns
A reference to the newli created connection or NULL if on_connected handler is provided. In both cases, the reference returned (or received at the on_connected handler) must be checked with myqtt_conn_is_ok.

About pending messages / queued messages

After successful connection with clean_session set to axl_false and defined client identifier, the library will resend any queued or in flight QoS1/QoS2 messages (as well as QoS0 if they were stored). This is done in background without intefering the caller.

If you need to get the number of queued messages that are going to be sent use myqtt_storage_queued_messages_offline. In the case you need the number remaining during the process use myqtt_storage_queued_messages.

About error error:140A90F1:SSL routines:SSL_CTX_new:unable to load ssl2 md5 routines

It has been reported that in some cases __myqtt_tls_conn_get_ssl_context fails to create the context (all to openssl SSL_CTX_new) by giving the aforementioned error. It is not clear why it happens but it seems to be related to the why openssl inits internal static structures and how they layed in memory when loading OpenSSL lib into the same binary/process but because linker dependencies as a consenquence of loading 2 modules which requires and inits it.

As a consequence, openssl library's last init takes over causing the first to lose internal references and hence, causing SSL_CTX_new to fail.

The solution is to:

1) Change the order the modules or libraries using OpenSSL are called

2) Ensure only one of them calls to init service internal (SSL_library_init)

3) Ensure modules using OpenSSL aren't unloaded when other modules (libraries) use them.