Comments (11)
It looks like the device isn't connected (ErrorCode:DeviceNotOnline
). Are you sure the device is connected, and is it connected via MQTT? Cloud-to-device methods are only supported currently for devices connected over MQTT.
from azure-iot-sdk-csharp.
@damonbarry yes the device is connected via MQTT. Also what is strange is that the error says Timed out waiting for device
, but the error response is returned in less than a second while timeout is set to 60 secs as you can see.
Any help is very much appreciated.
from azure-iot-sdk-csharp.
I searched for the Tracking ID in the IoT Hub instance diagnostic logs, but cannot find that record. Maybe someone in the IoT Hub team can look it up for more details about this error?
from azure-iot-sdk-csharp.
Is there a working end to end sample/test code available so we can see Direct Methods in action?
from azure-iot-sdk-csharp.
Below is the sample code for Methods on mqtt
https://github.com/Azure/azure-iot-sdk-csharp/blob/master/device/samples/DeviceClientMethodMqttSample/Program.cs
from azure-iot-sdk-csharp.
@jasmineymlo that sample is not applicable to this use case as it uses Devices Client and in our case we need to call the method from the Cloud.
from azure-iot-sdk-csharp.
Hi @tedvanderveen
You can find a sample here: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-csharp-node-direct-methods
We will need to update this doc to replace the device side code with the new C# samples that Jasmine was pointing to. In this doc you will find the service side of the sample in C#.
from azure-iot-sdk-csharp.
Thanks @olivierbloch but I tried it, still exactly same error. Did you try it and got successful results?
from azure-iot-sdk-csharp.
Hi @tedvanderveen.
I was indeed successful with both a device using the node sdk and also using the C# direct method sample.
Here is how I proceeded:
-
For Node
- I cloned the https://github.com/azure/azure-iot-sdk-node
- navigated in a prompt to the folder device/samples
- Ran the following commands
npm install
node device_method.js mydeviceconnectionsting
(using an actual connection string) - then I used the Device Explorer tool (just installed from latest release of this repo) to invoke the method "getDeviceLog"
- Got response in Device Explorer
-
For the C# sample:
- Cloned the current repo
- Opened the solution device/iothub_client_deviceclient.sln
- In the project Samples/DeviceClientMethodMqttSample, I edited the connection string, then built and ran (only this project, not the full solution) - Then I used the Device Explorer tool to invoke the method "GetDeviceName"
- Got response in Device Explorer.
Are you able to see telemetry data from the device in Device Explorer when running the sample DeviceClientMqttSample with the same connection string as the one you use for testing Methods?
from azure-iot-sdk-csharp.
@tedvanderveen - Closing. Please reopen if you're still having an issue.
from azure-iot-sdk-csharp.
Sorry for posting on an old topic, but for what it's worth, I hit this error when I connected directly via MQTT with mosquitto, but forgot to include the API version in the -user .azure-devices.net//api-version=2016-11-14.
If you leave off the /api-version bit, you can connect via mosquitto and get data on the /devices//messages/devicebound topic just fine, but the device twin and direct methods don't work.
from azure-iot-sdk-csharp.
Related Issues (20)
- [Technical Question] Security: Check root certificate on device-to-cloud connection HOT 10
- Unhandled exception. Microsoft.Azure.Devices.Client.Exceptions.IotHubException: Request 817bda7c-6fc4-40e0-8946-93eb851fcb12 returned status 403 [Bug Report] HOT 7
- [Bug Report] Send message in batch to multiple outputs using ModuleClient throws HOT 2
- Is it possible to send bulk messages in telemetry from device to IoT hub? [Technical Question]
- [Technical Question] HttpClientHelper error code 400030 HOT 3
- [Bug Report] When try to fetch reported properties after updating the reported property it will return previous version of reported property not the latest one. HOT 2
- [QUERY] How to properly acknowledge IoT hub messages HOT 6
- [feature request] Make DPS Queries testable HOT 2
- MQTT Channel is Closed / Migrating Sample to .net8 caused an issue HOT 5
- DeviceNotFoundException results in InvalidErrorCode (404103) HOT 2
- [Bug Report] v2.0.0 now removed from nuget package HOT 4
- Getting PlatformNotSupportedException on .NET Framework 4.6.1 HOT 3
- [Technical Question] HOT 1
- [Bug Report] HOT 2
- [Bug Report]Edgehub - Unknown feedback message - HOT 3
- Getting Connection Closed on New Connection Error when it was previously not generated HOT 2
- [Technical Question] Device Update for IoT Hub support HOT 1
- [Bug Report]DeviceClient.GetFileUploadSaSUriAsync() returns invalid SAS when hub is using System-identity. HOT 1
- Device Client Reconnects After Extended 'Disconnected_Retrying' State Without Entering 'Retry_Expired' as Documented HOT 1
- [Bug Report] SendEventAsync() hangs forever when the DeviceClient is Closed/Disposed while ConnectionStateChangedHandler is running
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-iot-sdk-csharp.