drogue-iot / drogue-cloud

Cloud Native IoT
https://drogue.io
Apache License 2.0
114 stars 30 forks source link

MQTTv5 sends out invalid subscription ID 0 #148

Closed jm-observer closed 3 years ago

jm-observer commented 3 years ago

when my device publish msg to sandbox.drogue.cloud, https://sandbox.drogue.cloud/spy can recv the msg. But I can't onsume device data using MQTT. publisher mqtt-client

ctron commented 3 years ago

Hm, this is strange. You command looks fine, and it works with my application.

Could you add -v to the command (after the "sub"), to enable logs. That might indicate what is wrong.

jm-observer commented 3 years ago

hello, this is the log:

huangjm@DESKTOP-06B3E7S:~$ mqtt sub -h mqtt-integration.sandbox.drogue.cloud -p 443 -s -t "app/some-app" -i client01 -v  -pw "... ..."
... ...
Client 'client01@mqtt-integration.sandbox.drogue.cloud' sending SUBSCRIBE MqttSubscribe{subscriptions=[MqttSubscription{topicFilter=app/some-app, qos=EXACTLY_ONCE, noLocal=false, retainHandling=SEND, retainAsPublished=false}]}
Client 'client01@mqtt-integration.sandbox.drogue.cloud' received SUBACK MqttSubAck{reasonCodes=[GRANTED_QOS_0], packetIdentifier=65526}

Client 'client01@mqtt-integration.sandbox.drogue.cloud' DISCONNECTED Exception while decoding PUBLISH: subscription identifier must not be 0
ctron commented 3 years ago

Interesting. I upgraded my MQTT client to version 4.7.2 and experience the same issue now.

Could you, just for testing, install version 4.6.2 of the MQTT client? And see if this "solves" the issue? I know this isn't a proper fix, but I would tell me if this is the same issue for you.

ctron commented 3 years ago

Looks like an upstream issue: https://github.com/ntex-rs/ntex-mqtt/issues/73

We will work on a fix. As a workaround, you could use MQTTv3.1.1 instead:

Add -V3 and use -u $(drg whoami -t) instead of the -pw for the token.

ctron commented 3 years ago

Fixed upstream. Will merge PR #152 once the CI looks good.

ctron commented 3 years ago

@fengqi2019 The issue is fixed on the main branch, as well as on the 0.7 release branch. The sandbox is also updated with the new 0.7.1 release, and I could verify that it works.

Thanks for reporting this!

It would be great if you could test yourself, and let us know if the issue is resolved for you too.