-
Notifications
You must be signed in to change notification settings - Fork 53
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
Unhandled ConnectionRefusedError #58
Comments
Actually this is expected behavior. Reconnects are good when you client is working, but connection at the moment becomes broken and after some time your client automatically reconnects. If the first connection attempt was unsuccessful, it probably means that configuration is bad, host, port or authorization method should be fixed. |
Hmmm, my use case is to embed mqtt client in IoT device and let it go into the wild, and report some data.
So if device reboots and goes through |
Hey @d21d3q |
@d21d3q does this resolve your problem? Can this issue be closed? |
I will have a look at it on Monday. Thank you. |
No, this is not the correct way of handling this. If you take a look at the Workaround is something like this:
|
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718033 If a server sends a CONNACK packet containing a non-zero return code it MUST then close the Network Connection [MQTT-3.2.2-5] gmqtt doesn't implement the MQTT standard for this particular point. |
@NICOLASGON Specification tells server must close the connection after it sends bad CONNACK package. gmqtt is about client relaization and docs do not specify any required actions after receiving bad connack code. |
@Lenka42 - Using the current master branch (as of 25 FEB 2022), what is the correct answer? This works: try: as does: try: And I see above the suggestion to catch OSError |
If you run properties example with host that is not running broker (eg localhost), program will crash
Expected behavior would be to try to reconnect normally.
workaround:
The text was updated successfully, but these errors were encountered: