-
Notifications
You must be signed in to change notification settings - Fork 1k
umqtt hangs when connecting to a MQTT v3.1 implementation on SUBACK #205
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
base: master
Are you sure you want to change the base?
Conversation
…tion type returns to subscribe channel it should be taking into account the 9 part of 0x9x, not the entire byte, as 1001 represent acknowledgement, regardless. 0x92 for example, and 0x90 should return the same operation code back to subscribe function to avoid a deadlock. Thingsboard for example, returns a 0x92 code as the octect instead of 0x90 as mosquitto. This fixes deadlock issues whiel trying to subscribe to Java MQTT implementations.
Thanks, but please follow https://github.com/micropython/micropython-lib/blob/master/CONTRIBUTING.md to format the commit message. And detailed commit message is great, but the final touch would be a reference to the MQTT spec section which mandates what you describe. |
OK. The problem really comes down to what version of the MQTT protocol umqtt is actually supporting. I couldn't find any indication in the source code of what version of MQQT the client supports. From the looks of the implementation it is MQTT v3.1.1. (msg = bytearray(b"\x04MQTT\x04\x02\0\0")). The server, at least in the io.netty java implementation ignores the protocol level, and acts according to the 3.1.1 spec "If the protocol name is incorrect the Server MAY disconnect the Client, or it MAY continue processing the CONNECT packet in accordance with some other specification. In the latter case, the Server MUST NOT continue to process the CONNECT packet in line with this specification" According to the specification for v3.1, In the specification for MQTT v3.1.1, The specification for 3.1.1. regarding flags, Perhaps the maintainer and main contributor of the umqtt module could comment on problem, and suggest a way we could either support v3.1, or simply specify that v3.1.1 is the only supported protocol, and hence change the behavior of the client on first connect to simply disconnected from a v3.1 MQTT implementation. |
This fix, which was not merged, helped me to subscribe to a Thingsboard MQTT implementation. I changed my local copy of simple.py to that trivial addition -- and am now making it past the nested wait_msg() inside subscribe() |
This modification is required for MQTT v3.1. I just spent a few days dissecting TCP packets to identify the issue before I came across this thread. Thanks @jrlomas for your lucid explanation. |
Correction to the mask on the return of the operation, when the operation type returns to subscribe channel it should be taking into account the 9 part of 0x9x, not the entire byte, as 1001 represent acknowledgement, regardless. 0x92 for example, and 0x90 should return the same operation code back to subscribe function to avoid a deadlock. Thingsboard implementation of mqtt for example, returns a 0x92 code as the ack for a subscribe instead of 0x90 as mosquitto. This fixes deadlock issues while trying to subscribe to Java MQTT implementations.