fwiw, our 1.1 code aborted if connect_async returned non success. Because in the past, it always succeeded. Now that it does make a connection attempt, blocking or not, we need to not actually care about the response being successful or not (other than MOSQ_ERR_INVAL) and simply carry on and make the call to _loop_start()
#define CFG_DEFAULT_MQ_HOST "127.0.0.1"
int connect_result = mosquitto_connect_async(st->mosq, CFG_DEFAULT_MQ_HOST, 1883, 90);
if (connect_result != MOSQ_ERR_SUCCESS) {
// oh, this looks really bad when this happens WLOG("Failed to create a thread for connecting to %s: code:%d, reason: %s\n",
CFG_DEFAULT_MQ_HOST, connect_result, strerror(errno));
// XXX DON'T ABORT HERE ON MOSQUITTO 1.2!
// return false;
}
// okay, "connected", lets go...
// start looping in a thread, this also reconnects if necessary!! ILOG("Starting mosquitto loop thread\n");
int loop_result = mosquitto_loop_start(st->mosq);
if (loop_result != MOSQ_ERR_SUCCESS) {
// oh, this looks really bad again give up! WLOG("Failed to create a thread for looping mosquitto.\n"); return false;
}
// everything fine
return true;
fwiw, our 1.1 code aborted if connect_async returned non success. Because in the past, it always succeeded. Now that it does make a connection attempt, blocking or not, we need to not actually care about the response being successful or not (other than MOSQ_ERR_INVAL) and simply carry on and make the call to _loop_start()
#define CFG_DEFAULT_MQ_HOST "127.0.0.1" connect_ async(st- >mosq, CFG_DEFAULT_ MQ_HOST, 1883, 90);
int connect_result = mosquitto_
if (connect_result != MOSQ_ERR_SUCCESS) {
WLOG( "Failed to create a thread for connecting to %s: code:%d, reason: %s\n", DEFAULT_ MQ_HOST, connect_result, strerror(errno));
ILOG(" Starting mosquitto loop thread\n"); loop_start( st->mosq) ;
WLOG( "Failed to create a thread for looping mosquitto.\n");
return false;
// oh, this looks really bad when this happens
CFG_
// XXX DON'T ABORT HERE ON MOSQUITTO 1.2!
// return false;
}
// okay, "connected", lets go...
// start looping in a thread, this also reconnects if necessary!!
int loop_result = mosquitto_
if (loop_result != MOSQ_ERR_SUCCESS) {
// oh, this looks really bad again give up!
}
// everything fine
return true;
User error I guess :)