Receiving acknowledgements using IoT Hub

穿精又带淫゛_ 提交于 2019-12-25 09:13:09

问题


When using DeviceClient I can send messages using SendEvent and files using SendBlob. But I did not find a way to receive acknowledgement that messages/files have been received by Azure IoT Hub?

The only way I found to solve this is using serviceClient.GetFileNotificationReceiver(). Am I missing something or is this the only way?

Also it seems I need SharedAccessKeyName to use ServiceClient. But this is not present in e.g. tokens created by DeviceExplorer (which I use for DeviceClient). Any advice is appreciated.


回答1:


For Java and C sdks there are IotHubEventCallback and IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK but for C# there is no such interface implemented.

So, for C#, a message will be sent successfully if DeviceClient.SendEventAsync() without throwing any exception, otherwise it fails.

Or you can utilize Event Hub-compatible endpoint to monitor the status of operations on your IoT hub, D2C message, file upload...

For ServiceClient, you need Azure IoT Hub connection string, not device connection string. You can find it in Configuration of Device Explorer:



来源:https://stackoverflow.com/questions/45701047/receiving-acknowledgements-using-iot-hub

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!