damienpontifex / azure-iot-sdk-rs

A rust library for connecting devices to Microsoft Azure IoT Hub
MIT License
14 stars 11 forks source link

Example stops working after a DirectMessage #38

Closed ghost closed 3 years ago

ghost commented 3 years ago

I am trying to chase down an issue with DirectMethodInvocation in the latest version causing the message loop to halt. To reproduce, just run the example (temperature-client), and then send a direct method call to the device via the Azure portal. Here is what happened when I did that:

2020-11-13 21:40:59,347 TRACE [azure_iot_sdk::mqtt_transport] Sending message Message { body: [123, 34, 116, 105, 109, 101, 115, 116, 97, 109, 112, 34, 58, 34, 50, 48, 50, 48, 45, 49, 49, 45, 49, 52, 84, 48, 53, 58, 52, 48, 58, 53, 57, 46, 51, 52, 55, 55, 53, 55, 90, 34, 44, 34, 104, 117, 109, 105, 100, 105, 116, 121, 34, 58, 53, 54, 46, 57, 48, 55, 48, 53, 53, 125], properties: {}, system_properties: {"$.mid": "2-h"} } to topic TopicName("devices/edb126bb-51a2-4154-8172-707f19ffce3b-DE/messages/events/%24.mid=2-h")
2020-11-13 21:41:01,351 TRACE [azure_iot_sdk::mqtt_transport] Sending message Message { body: [123, 34, 116, 105, 109, 101, 115, 116, 97, 109, 112, 34, 58, 34, 50, 48, 50, 48, 45, 49, 49, 45, 49, 52, 84, 48, 53, 58, 52, 49, 58, 48, 49, 46, 51, 53, 49, 50, 54, 53, 90, 34, 44, 34, 116, 101, 109, 112, 101, 114, 97, 116, 117, 114, 101, 34, 58, 50, 55, 46, 55, 52, 48, 56, 54, 54, 125], properties: {}, system_properties: {"$.mid": "6-t"} } to topic TopicName("devices/edb126bb-51a2-4154-8172-707f19ffce3b-DE/messages/events/%24.mid=6-t")
2020-11-13 21:41:03,346 TRACE [azure_iot_sdk::mqtt_transport] Sending message Message { body: [123, 34, 116, 105, 109, 101, 115, 116, 97, 109, 112, 34, 58, 34, 50, 48, 50, 48, 45, 49, 49, 45, 49, 52, 84, 48, 53, 58, 52, 49, 58, 48, 51, 46, 51, 52, 54, 50, 51, 55, 90, 34, 44, 34, 116, 101, 109, 112, 101, 114, 97, 116, 117, 114, 101, 34, 58, 50, 46, 51, 51, 50, 48, 53, 54, 125], properties: {}, system_properties: {"$.mid": "7-t"} } to topic TopicName("devices/edb126bb-51a2-4154-8172-707f19ffce3b-DE/messages/events/%24.mid=7-t")
2020-11-13 21:41:04,347 TRACE [azure_iot_sdk::mqtt_transport] Sending message Message { body: [123, 34, 116, 105, 109, 101, 115, 116, 97, 109, 112, 34, 58, 34, 50, 48, 50, 48, 45, 49, 49, 45, 49, 52, 84, 48, 53, 58, 52, 49, 58, 48, 52, 46, 51, 52, 55, 49, 55, 51, 90, 34, 44, 34, 104, 117, 109, 105, 100, 105, 116, 121, 34, 58, 53, 54, 46, 56, 50, 52, 51, 48, 51, 125], properties: {}, system_properties: {"$.mid": "3-h"} } to topic TopicName("devices/edb126bb-51a2-4154-8172-707f19ffce3b-DE/messages/events/%24.mid=3-h")
2020-11-13 21:41:05,346 TRACE [azure_iot_sdk::mqtt_transport] Sending message Message { body: [123, 34, 116, 105, 109, 101, 115, 116, 97, 109, 112, 34, 58, 34, 50, 48, 50, 48, 45, 49, 49, 45, 49, 52, 84, 48, 53, 58, 52, 49, 58, 48, 53, 46, 51, 52, 54, 52, 53, 49, 90, 34, 44, 34, 116, 101, 109, 112, 101, 114, 97, 116, 117, 114, 101, 34, 58, 51, 51, 46, 48, 54, 49, 55, 125], properties: {}, system_properties: {"$.mid": "8-t"} } to topic TopicName("devices/edb126bb-51a2-4154-8172-707f19ffce3b-DE/messages/events/%24.mid=8-t")
2020-11-13 21:41:07,346 TRACE [azure_iot_sdk::mqtt_transport] Sending message Message { body: [123, 34, 116, 105, 109, 101, 115, 116, 97, 109, 112, 34, 58, 34, 50, 48, 50, 48, 45, 49, 49, 45, 49, 52, 84, 48, 53, 58, 52, 49, 58, 48, 55, 46, 51, 52, 54, 52, 48, 56, 90, 34, 44, 34, 116, 101, 109, 112, 101, 114, 97, 116, 117, 114, 101, 34, 58, 50, 53, 46, 54, 52, 49, 55, 56, 125], properties: {}, system_properties: {"$.mid": "9-t"} } to topic TopicName("devices/edb126bb-51a2-4154-8172-707f19ffce3b-DE/messages/events/%24.mid=9-t")
2020-11-13 21:41:08,298 TRACE [azure_iot_sdk::mqtt_transport] Received PACKET PublishPacket(PublishPacket { fixed_header: FixedHeader { packet_type: PacketType { control_type: Publish, flags: 0 }, remaining_length: 41 }, topic_name: TopicName("$iothub/methods/POST/FooBer/?$rid=1"), packet_identifier: None, payload: [110, 117, 108, 108] })
2020-11-13 21:41:08,299 TRACE [azure_iot_sdk::mqtt_transport] PUBLISH ($iothub/methods/POST/FooBer/?$rid=1): Message { body: [110, 117, 108, 108], properties: {}, system_properties: {} }
2020-11-13 21:41:08,299 INFO  [hello] Received direct method DirectMethodInvocation { method_name: "FooBer", message: Message { body: [110, 117, 108, 108], properties: {}, system_properties: {} }, request_id: "1" }
2020-11-13 21:41:08,299 TRACE [azure_iot_sdk::mqtt_transport] Responding to direct method with rid = 1

After the last message, I got no further logging at all. In my own version I have error handling (crude) enabled, and after the response to the direct method, all further calls to

           while let Some(msg) = receiver.recv().await {

fail immediately. Any ideas as to what is going on?

ghost commented 3 years ago

This is fixed on 0.6.0.