-
Notifications
You must be signed in to change notification settings - Fork 724
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
why connect() returns but connection is not established? #454
Comments
Have the same problem and can't find a solution. client.connect(..) returns 0 (MQTT_ERR_SUCCESS) so no error occur while connecting. |
I have another python script to publish data to mqtt.
client.is_connected() returns False but data get published to the mqtt broker. |
same here |
observing the same behavior |
For me was the problem, that I used websockets at the mqtt broker and forgot to specify that while creating the client. |
Same issue here. |
I'm working with AWSIoT. |
Same issue here. is_connected() always returns False, but MQTT data is being published. I have also overridden the on_connect and on_disconnect callbacks and they are never triggered. |
Have the same problem |
Ran into a similar problem, I didn't know that calling |
Same here. I am using mqtt_bridge. every time , the on_disconnect will give the response code 1 back . I do not know how to solve it. |
Connecting to a broker is a two stage process:
Taking a look at the source it appears that
This has a few implications:
The above is my assessment based upon a review of the code; I'd appreciate it if someone could confirm my findings and I'll propose some updates to the docs. |
Made cool workaround: def connect():
client = mqtt.Client()
client.connect(host="host", port="port")
started = time.time()
while time.time() - started < 5.0:
client.loop()
if client.is_connected():
return client
raise OSError('Not connected') |
Closing this because my PR (#615) to update the documentation has now been accepted. Hopefully that will clarify things a bit! |
paho version is 1.5.0, python 3.8
code example:
client.connect(host=self.__profile.get_host(), port=self.__profile.get_port(),
keepalive=self.__profile.get_keep_alive_interval())
client.loop_start()
client.is_connected()
but client.is_connect() reslut is false. why sync method connect returns but connection is not established?
The text was updated successfully, but these errors were encountered: