Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation/comments for connect() ref blocking #615

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,10 @@ connect()

connect(host, port=1883, keepalive=60, bind_address="")

The ``connect()`` function connects the client to a broker. This is a blocking
function. It takes the following arguments:
The ``connect()`` function connects the client to a broker. ``connect()`` blocks until
the underlying connection is established and a CONNECT packet transmitted.
Note that the connection status will not be updated until a CONNACK is received and
processed (this requires a ``loop*()`` function).

host
the hostname or IP address of the remote broker
Expand All @@ -465,11 +467,17 @@ bind_address
the IP address of a local network interface to bind this client to,
assuming multiple interfaces exist

Returns MQTT_ERR_SUCCESS if the underlying connection was successfully established
and an MQTT CONNECT packet sent.

Callback
........

When the client receives a CONNACK message from the broker in response to the
connect it generates an ``on_connect()`` callback.
When the client ``loop*()`` function receives a CONNACK packet from the broker in
response to the CONNECT packet it generates an ``on_connect()`` callback.

In most cases the connection should not be used prior to the ``on_connect()`` call
because the broker may reject the CONNECT packet.

Connect Example
...............
Expand Down
3 changes: 2 additions & 1 deletion src/paho/mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,8 @@ def disable_logger(self):

def connect(self, host, port=1883, keepalive=60, bind_address="", bind_port=0,
clean_start=MQTT_CLEAN_START_FIRST_ONLY, properties=None):
"""Connect to a remote broker.
"""Connect to a remote broker. This is a blocking call that establishes
the underlying connection and transmits a CONNECT packet.

host is the hostname or IP address of the remote broker.
port is the network port of the server host to connect to. Defaults to
Expand Down