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;

User error I guess :)

-- 
You received this bug notification because you are a member of Mosquitto
Development, which is subscribed to mosquitto.
https://bugs.launchpad.net/bugs/1212786

Title:
  mosquitto_connect_async seems to be blocking since version 1.2

Status in mosquitto: an mqtt message broker:
  Confirmed

Bug description:
  I just downloaded version 1.2 and mosquitto_connect_async is now
  blocking when connecting to server. Such behavior was not present on
  the version 1.1.3 i was using.

To manage notifications about this bug go to:
https://bugs.launchpad.net/mosquitto/+bug/1212786/+subscriptions

-- 
Mailing list: https://launchpad.net/~mosquitto-devel
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~mosquitto-devel
More help   : https://help.launchpad.net/ListHelp

Reply via email to