You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by hackerick4 <ha...@gmail.com> on 2017/11/21 02:56:21 UTC
Connecting to invalid URI leads program crash.
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
Re: Connecting to invalid URI leads program crash.
Posted by Timothy Bish <ta...@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/