0
votes

I am trying to use Direct Method to invoke device OTA The device I am using is Quectel EC21 and subscribe to the topic "$iothub/methods/POST/#" When I Invoke the method in Azure IoT explorer,I always get the time out fail message that "message":"Timed out waiting for device to connect." enter image description here

This error message confused me since I expect my device receive the method payload through MQTT from topic "$iothub/methods/POST/#" but I received nothing. But at he same time, I can receive normal cloud to device MQTT message through topic "devices/deviceID/messages/devicebound/#" So, is the Direct method connection and Iot hub connection are different connection?

1
$iothub/methods/POST/# is the correct topic, and you should receive a message there. The timeout will occur if you don't to respond to the message. But if I read your question right, you are not even receiving the message on the device right now? Can you include some code?Matthijs van der Veer
Hi Matthijs, I am using a real IOT device, so the code is embedded C to send AT command through UART, so, I am not sure it I post code will make work. I just want to make sure that this topic $iothub/methods/POST/# should work like devices/{deviceID}/messages/devicebound/# right? since I can receive message from devices/{deviceID}/messages/devicebound/# but not $iothub/methods/POST/#doushicai
Yes, $iothub/methods/POST/# is correct. Your method will eventually come in as $iothub/methods/POST/methodname/?$rid=1. One important thing to note, if your device does receive the message but does not respond to it, IoT Hub will consider it a timeout.Matthijs van der Veer
actually, my problem is exactly cannot receive anything from $iothub/methods/POST/# on my device. I also try third party MQTT client MQTT.fx to sub this topic but can get nothing neither. However, both my device and MQTT.fx can receive message from devices/{deviceID}/messages/devicebound/#doushicai
I understand, could you expand your question with how you authenticate with your hub? How do you structure your username, connection string and password would be helpful.Matthijs van der Veer

1 Answers

0
votes

After searching online and hint from Matthijs. To make the direct method work, I found need to add api version in username field as below For the Username field, use {iothubhostname}/{device_id}/?api-version=2018-06-30