Connecting to invalid URI leads program crash.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Connecting to invalid URI leads program crash.

hackerick4
Hello guys,
I was using Paho C library but found a issue. I'm not it's a bug or not.
Here are several lines of codes in C.  URI1 and URI2 are in valid URI for
active MQ,
Why the MQTTAsync_connect function didn't report any error but success ? and
the program would crash after a few seconds.

I am sure the code is normal if one of URIs is valid.


               char* arr[] = { URI1, URI2 };
                conn_opts.keepAliveInterval = 20;
                conn_opts.connectTimeout = 1;
                conn_opts.cleansession = 1;
                conn_opts.onSuccess = onConnect;
                conn_opts.onFailure = onConnectFailure;
                conn_opts.context = client;
                conn_opts.serverURIs = arr;
                conn_opts.serverURIcount = 2;
               
                if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS) {
                        logger << _ERROR << "Failed to start connect, return code : " << rc <<
endl;
                }



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: Connecting to invalid URI leads program crash.

tabish121@gmail.com
On 11/20/2017 09:56 PM, hackerick4 wrote:

> Hello guys,
> I was using Paho C library but found a issue. I'm not it's a bug or not.
> Here are several lines of codes in C.  URI1 and URI2 are in valid URI for
> active MQ,
> Why the MQTTAsync_connect function didn't report any error but success ? and
> the program would crash after a few seconds.
>
> I am sure the code is normal if one of URIs is valid.
>
>
>                 char* arr[] = { URI1, URI2 };
>                  conn_opts.keepAliveInterval = 20;
> conn_opts.connectTimeout = 1;
> conn_opts.cleansession = 1;
> conn_opts.onSuccess = onConnect;
> conn_opts.onFailure = onConnectFailure;
> conn_opts.context = client;
> conn_opts.serverURIs = arr;
> conn_opts.serverURIcount = 2;
>
> if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS) {
> logger << _ERROR << "Failed to start connect, return code : " << rc <<
> endl;
> }
>
>
>
> --
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>
This ActiveMQ community doesn't maintain the Paho C client so asking
here probably won't get you much if any answers, you'd be better served
by asking this in the Paho community.

--
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/