Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] python paho-mqtt 1.1 connect() not blocking?

Hi Randy,

connect() is definitely blocking, but maybe not in quite the way you are thinking. It blocks until the TCP connection with the server in complete, but this doesn't mean that the mqtt CONNECT/CONNACK flow is complete.

This shouldnt actually matter though, because calling subscribe() immediately after connect() should work fine. What error do you get?

Are you calling loop_start() or loop_forever() after the call to subscribe?

Cheers,

Roger

On 11 Dec 2015 01:29, "Randy Forbes" <randy.forbes@xxxxxxxxx> wrote:
python: 3.4.2
paho-mqtt: 1.1
os: raspian-jessie

According to the following documentation: https://pypi.python.org/pypi/paho-mqtt/1.1 the connect() call is supposed to be a blocking function.

**********
The connect() function connects the client to a broker. This is a blocking function.

**********

In my usage of the library, this appears to not be the case. I attempted to execute a subscribe() immediately after a connect but was not successful in getting subscribed. Moving the subscribe into onconnect() did work but indicated that the documentation may be incorrect.

In viewing the source, it appears that connect() calls into connect_async() which would make it a non-blocking call.

Am I correct in my observations?

Kind Regards.

Randy Forbes

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev

Back to the top