mosquitto_connect_async seems to be blocking since version 1.2

Bug #1212786 reported by onaips
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mosquitto
Confirmed
Undecided
Unassigned

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.

Revision history for this message
Roger Light (roger.light) wrote :

In 1.1.x mosquitto_connect_async() didn't actually attempt any connection. It does now and makes a non-blocking connection. The problem is that the DNS lookups are still blocking. If you use an IP address instead of a hostname it should work just fine. I realise this isn't an ideal situation!

Changed in mosquitto:
status: New → Confirmed
Revision history for this message
Karl Palsson (ubuntu-tweak) wrote :

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 :)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.